Firebase Google Auth离线访问类型,以获得令牌刷新 [英] Firebase Google Auth offline access_type in order to get a token refresh

查看:186
本文介绍了Firebase Google Auth离线访问类型,以获得令牌刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用firebase与谷歌身份验证。我们选择了Google,因为我们的应用程序会进行Google API调用我们使用包含在从firebase返回的授权有效内容中的access_token来授权这些api调用。但是,我们在计算过期后如何刷新access_token时遇到问题。根据谷歌,我们应该认为access_token可能会由于各种原因失效。所以,(据我所知),我们需要一种刷新这个令牌的方法,而不用强制用户重新授权。理想情况下,我可以请求离线access_type当请求firebase身份验证...但我不知道如何做到这一点(短触发firebase.authWithOAuthPopup(...)再次,我们绝对不想做用户会话显然仍然有效。



是否可以通过Firebase获得离线access_type Google oauth标记,以便Google返回refresh_token( https://developers.google.com/accounts/docs/OAuth2WebServer#formingtheurl )?有了refresh_token,我想我可以为api调用抓取一个新的access_token。



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

<$ p $ this.firebase.authWithOAuthPopup(google,this.authenticateGoogle.bind(this),{
access_type:'offline',< - 不传递给Google
范围: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的 Rob DiMarco :不幸的是,目前无法通过Firebase获取Google OAuth刷新令牌,虽然这是我们意识到并希望解决的问题。


We are using firebase with google authentication. We chose Google because our application makes Google API calls. We authorize these api calls with the access_token included in authorization payload that is returned from firebase. However, we are having trouble figuring out how to refresh the access_token after it expires. According to Google, we should assume the access_token may expire for various reasons.

Therefore, (as I understand it) we need a way to refresh this token without forcing the user to reauthorize. Ideally, I could request the offline access_type when requesting the firebase auth...but I dont see how to do that (short of triggering firebase.authWithOAuthPopup(...) again, which we absolutely do not want to do as the users session is obviously still valid.

Is it possible to get an offline access_type Google oauth token through Firebase so that Google will return a refresh_token (https://developers.google.com/accounts/docs/OAuth2WebServer#formingtheurl)? With a refresh_token, I think I can grab a new access_token for api calls.

I was trying this but its definitely not supported:

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'
});

All calls to https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=abcd show the access_type as online.

Thanks

解决方案

SOLVED for now. According to Rob DiMarco from Firebase: "Unfortunately, it is not currently possible to get a Google OAuth refresh token via Firebase, though it's something we're aware of and hope to fix."

这篇关于Firebase Google Auth离线访问类型,以获得令牌刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆