def _GetTokenInfo(access_token):
"""Return the list of valid scopes for the given token as a list."""
url = _OAUTH2_TOKENINFO_TEMPLATE.format(access_token=access_token)
h = httplib2.Http()
response, content = h.request(url)
if 'status' not in response:
raise ValueError('No status in HTTP response')
status_code = int(response['status'])
if status_code not in [http_client.OK, http_client.BAD_REQUEST]:
msg = (
'Error making HTTP request to <{}>: status <{}>, '
'content <{}>'.format(url, response['status'], content))
raise ValueError(msg)
if status_code == http_client.BAD_REQUEST:
return {}
return json.loads(_AsText(content))
评论列表
文章目录