Google OAuth: can't get refresh token with authorization code

前端 未结 2 1413
故里飘歌
故里飘歌 2021-01-23 03:59

I am using Google API Client for Google Analytics with OAuth 2.0

I read this to get the refresh token but it doesn\'t appears: https://developers.google.com/identity/pro

2条回答
  •  無奈伤痛
    2021-01-23 04:05

    You will only get the refresh_token the very first time that a user grants access to your app. You'll need to store the refresh_token somewhere to be able to use it afterwards. You won't get a new refresh token the next time a user logs in to your app.

    FWIW: using a refresh token in a Javascript client doesn't make a lot of sense since a Javascript client can't store it in a safe (confidential) way. Since Javascript clients live in browsers and users are present in browsers, you can just redirect the browser to the authorization endpoint again and you'll get a new access token (which is also the purpose of a refresh token). The SSO session for the user at Google will make sure that the user doesn't need to login again and that the experience is seamless.

提交回复
热议问题