【问题标题】:Firebase Google Auth offline access_type to get a refresh_tokenFirebase Google Auth 离线 access_type 以获取 refresh_token
【发布时间】:2020-01-28 22:59:38
【问题描述】:

我们正在使用带有 google 身份验证的 firebase。我们选择 Google 是因为我们的应用程序会调用 Google API。 我们使用从 firebase 返回的授权负载中包含的 access_token 来授权这些 api 调用。 但是,我们无法弄清楚如何在 access_token 过期后刷新它。

我们需要一种在不强制用户重新授权的情况下刷新此令牌的方法。 理想情况下,我可以在请求 firebase 身份验证时请求离线 access_type ... 是否可以通过 Firebase 获取离线 access_type Google oauth 令牌,以便 Google 返回 refresh_token? 使用 refresh_token,我想我可以为 api 调用获取一个新的 access_token。

我正在尝试这个,但它绝对不支持:

const provider = new firebase.auth.GoogleAuthProvider()
provider.addScope('https://www.googleapis.com/auth/calendar')
provider.setCustomParameters({ access_type: 'offline' }) // not work
firebase.auth().signInWithRedirect(provider)

【问题讨论】:

    标签: firebase google-api firebase-authentication google-api-nodejs-client


    【解决方案1】:

    很遗憾,目前无法通过 Firebase 获取 Google OAuth 刷新令牌 除了 firebase auth 之外,还可以使用 here 中的单独代码来获取访问令牌/刷新令牌。

    Firebase 身份验证的 access_token/refresh_token 不适用于 Google API

    【讨论】:

      猜你喜欢
      • 2015-03-09
      • 2016-10-18
      • 2014-04-24
      • 2018-07-31
      • 2015-05-26
      • 2017-04-29
      • 1970-01-01
      • 1970-01-01
      • 2017-11-10
      相关资源
      最近更新 更多