我们正在使用带google身份验证的firebase。我们选择Google是因为我们的应用程序会调用Google API。我们使用从firebase返回的授权负载中包含的access_token来授权这些api调用。然而,我们在弄清楚如何在access_token到期后刷新它时遇到了麻烦。
我们需要一种在不强制用户重新授权的情况下刷新该令牌的方法。理想情况下,我可以在请求firebase身份验证时请求离线access_type ...有没有可能通过Firebase获得一个离线的access_type 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)发布于 2021-07-19 23:04:04
不幸的是,除了Firebase身份验证之外,目前还不能通过firebase使用单独的代码(如here中的代码)来获取访问令牌/刷新令牌。
Firebase身份验证的access_token/refresh_token不适用于Google API
https://stackoverflow.com/questions/58154504
复制相似问题