首页 > 解决方案 > 在 react-google-login 上使用 uxMode="redirect" 时获取 access_token

问题描述

我使用'react-google-login'。我需要将 access_token 发送到后端,当我使用 uxMode="popup" 时,会调用 onSuccess 函数,因此我可以从响应中获取 access_token。

但我想使用 uxMode="redirect"。这是我的代码:

<GoogleLogin
              clientId="..."
              buttonText="go to sign in"
              onSuccess={::this.responseGoogle}
              onFailure={::this.errorGoogle}
              onRequest={::this.onRequest}
              uxMode='redirect'
              redirectUri={window.location.origin + '/auth/google/callback'}
            />

它不调用 onSuccess 函数并重定向到“/auth/google/callback”。我无法从 location.hash 中获取此参数(但它具有 id_token)。我可以从什么获得 access_token 并且有可能吗?

标签: reactjsaccess-tokengoogle-signin

解决方案


推荐阅读