Search code examples
google-apigoogle-oauthgoogle-python-api

Manually update access_token for google oauth2 in python


I'm using google oauthlib to get an access_token and use it to get gmail atom feed using requests because it is not supported by the python lib.

When using supported services such as drive, the token is automatically refreshed, how to do that in my case?


Solution

  • Assuming you have your refresh token you can use it to request a new Access token using HTTP POST

    https://accounts.google.com/o/oauth2/token
    

    client_id={ClientId}.apps.googleusercontent.com&client_secret={ClientSecret}&refresh_token=1/ffYmfI0sjR54Ft9oupubLzrJhD1hZS5tWQcyAvNECCA&grant_type=refresh_token

    this Link may help Google 3 legged oauth2 flow