相关疑难解决方法(0)

Firebase Google Auth离线access_type以获取令牌刷新

我们正在使用带有Google身份验证的firebase.我们选择Google是因为我们的应用程序会调用Google API.我们使用从firebase返回的授权有效负载中包含的access_token授权这些api调用.但是,我们无法确定如何在access_token到期后刷新它.根据Google的说法,我们应该假设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'
});
Run Code Online (Sandbox Code Playgroud)

所有拨打https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=abcd的电话都会将access_type显示为在线.

谢谢

firebase google-oauth firebase-security

9
推荐指数
2
解决办法
2544
查看次数

如何使用 Firebase 身份验证获取 google api 的刷新令牌

来自 firebase 的文档

firebase.auth().signInWithPopup(provider).then(function(result) {
// This gives you a Google Access Token. You can use it to access the 
Google API.
var token = result.credential.accessToken;
// The signed-in user info.
var user = result.user;
// ...
}).catch(function(error) {
 // Handle Errors here.
 var errorCode = error.code;
var errorMessage = error.message;
// The email of the user's account used.
var email = error.email;
// The firebase.auth.AuthCredential type that was used.
var credential = error.credential;
// ...
});
Run Code Online (Sandbox Code Playgroud)

无论如何我可以使用firebase身份验证获取google api的刷新令牌。我在 Firebase …

google-api firebase firebase-authentication

5
推荐指数
1
解决办法
3330
查看次数