【发布时间】:2015-03-09 13:19:27
【问题描述】:
我们正在使用带有 google 身份验证的 firebase。我们选择 Google 是因为我们的应用程序会调用 Google API。我们使用从 firebase 返回的授权负载中包含的 access_token 来授权这些 api 调用。但是,我们无法弄清楚如何在 access_token 过期后刷新它。根据谷歌的说法,我们应该假设 access_token 可能由于各种原因而过期。
因此,(据我了解)我们需要一种方法来刷新此令牌,而无需强制用户重新授权。理想情况下,我可以在请求 firebase auth 时请求离线 access_type ......但我不知道如何做到这一点(没有再次触发 firebase.authWithOAuthPopup(...) ,我们绝对不想作为用户会话做显然仍然有效。
是否可以通过 Firebase 获取离线 access_type Google oauth 令牌,以便 Google 返回 refresh_token (https://developers.google.com/accounts/docs/OAuth2WebServer#formingtheurl)?使用 refresh_token,我想我可以为 api 调用获取一个新的 access_token。
我正在尝试这个,但它绝对不支持:
this.firebase.authWithOAuthPopup("google", this.authenticateGoogle.bind(this), {
access_type: 'offline', <-- not passed to Google
scope: 'https://www.googleapis.com/auth/userinfo.profile, https://www.googleapis.com/auth/devstorage.read_write'
});
对https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=abcd 的所有调用都将 access_type 显示为在线。
谢谢
【问题讨论】:
-
很遗憾,目前无法通过 Firebase 获取 Google OAuth 刷新令牌,但我们已经知道并希望解决此问题。
-
既然这回答了这个问题,那应该是一个答案。
标签: firebase google-oauth firebase-security