【发布时间】: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