Not receiving Google OAuth refresh token

前端 未结 14 1805
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-22 07:38

I want to get the access token from Google. The Google API says that to get the access token, send the code and other parameters to token generating page, and the response

14条回答
  •  佛祖请我去吃肉
    2020-11-22 08:22

    1. How to get 'refresh_token' ?

    Solution: access_type='offline' option should be used when generating authURL. source : Using OAuth 2.0 for Web Server Applications

    2. But even with 'access_type=offline', I am not getting the 'refresh_token' ?

    Solution: Please note that you will get it only on the first request, so if you are storing it somewhere and there is a provision to overwrite this in your code when getting new access_token after previous expires, then make sure not to overwrite this value.

    From Google Auth Doc : (this value = access_type)

    This value instructs the Google authorization server to return a refresh token and an access token the first time that your application exchanges an authorization code for tokens.

    If you need 'refresh_token' again, then you need to remove access for your app as by following the steps written in Rich Sutton's answer.

提交回复
热议问题