oauthgoogle-apigoogle-oauthoauth2-playground

GoogleAPI oauth2 refresh token expires in 1 hour


I am using Google APIs in my application and the oauth2 refresh token expires after 1 hour. I am using this refresh token to execute a task which runs daily. I create the refresh token using the OAuth2 playground. Is there a way to extend the expiration time of a refresh token? (1 month)


Solution

  • I think that you have your terms confused here.

    As per Oauth2 access tokens expire after one hour. Access tokens are used to request access of an api and return the data that you need. There is no way to extend the lifetime of an access token beyond one hour. You need to use a refresh token to request a new access token.

    Refresh tokens are extremely long lived and do not normally expire. Refresh tokens are used to request a new access token. Refresh tokens for the most part do not expire if one is not used in six months though google will automatically expire it. Also if the user removes your access then the refresh token will also automatically expire.

    If you are creating your refresh token using the Outh2 playground which is intended only for testing purposes it will also expire.

    If you are using the oauth2 playground to create your refresh token then you should not be doing this you should be creating your own application to request the tokens.