【问题标题】:Google auth2 .getCurrentUser() get the user token?Google auth2 .getCurrentUser() 获取用户令牌?
【发布时间】:2020-05-05 19:55:05
【问题描述】:

我在前端使用 react,后端使用 nodeJS。

我正在尝试从前端进行 google auth2 登录流程。

我在哪里可以从 google auth2 登录获取令牌?

我在Zi.access_token 下的回复中看到了它,但在我看来这不是获取它的正确方法。

【问题讨论】:

    标签: reactjs authentication oauth-2.0 google-authentication


    【解决方案1】:

    为了访问basic_profileaccess_token 等属性,Auth2 库提供了一系列 getter 函数,可让您以可预测的方式访问数据。

    对于access_token,你应该在成功登录返回的GoogleUser对象上调用函数getAuthResponse(),这个GoogleUser对象将包含一个明确标记为access_token的键

    对于basic_profile,提供GoogleUser.getBasicProfile()


    我在 Zi.access_token 下的响应中看到它,但在我看来这不是获取它的正确方法。

    你是对的,这也许是文档可以提到的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-08-06
      • 2013-04-06
      • 2022-10-15
      • 1970-01-01
      • 2016-10-13
      • 2015-04-09
      • 1970-01-01
      • 2014-11-06
      相关资源
      最近更新 更多