Failed to resolve tokeninfo oauth2 request using decorator.http ()

To access TokenInfo, I use the Google API client library for Python (the oauth2client application engine). I got the oauth2 access token, and this code works fine:

@decorator.oauth_aware def get(self): .... .... if decorator.has_credentials() : body = urllib.urlencode({'access_token': decorator.credentials.access_token}) http = httplib2.Http() resp, content = http.request("https://www.googleapis.com/oauth2/v1/tokeninfo",method="POST", body=body) 

But when I use the decorator to create an authorized http instance:

 @decorator.oauth_aware def get(self): .... .... if decorator.has_credentials() : http = decorator.http() resp, content = http.request("https://www.googleapis.com/oauth2/v1/tokeninfo",method="POST") 

I get:

 'status' : '400' { "error": "invalid_token", "error_description": "either access_token or id_token required" } 

UPDATE-1

I studied oauth2client \ client.py: decorator.http () not only resolves the request, but also updates the access_token if it has expired.

I really welcome ideas on how to solve this? Thank you for your help.

UPDATE-2 AND SOLVED

The TokeInfo API does not need authorization. The request itself must contain access_token. The authorization header is ignored.

+1
source share
1 answer

I studied oauth2client \ client.py: decorator.http () not only resolves the request, but also updates the access_token if it has expired.

I really welcome ideas on how to solve this? Thank you for your help.

UPDATE AND DECISION

The TokeInfo API does not need authorization. The request itself must contain access_token. The authorization header is ignored.

+2
source

Source: https://habr.com/ru/post/1440067/


All Articles