Firebase 3 - Additional Auth Scope Data

做~自己de王妃 提交于 2019-12-07 04:06:43

问题


In the Firebase 3 documentation, they say you can grab additional scope data such as this one:

Optional: Specify additional OAuth 2.0 scopes that you want to request from the authentication provider. To add a scope, call addScope. For example: provider.addScope('https://www.googleapis.com/auth/plus.login');

Once authenicated, I can't find the data as part of the "user" object. Any idea how to pick that extra data ?

Thank you,


回答1:


Firebase V3 will not return the additional requested data when additional OAuth 2.0 scopes are requested. What you need to do is retrieve the credential returned (signInWithPopup and getRedirectResult provide that) and then using the Google accessToken in the credential call the google api to request the additional data.




回答2:


I have tested this out and using Github as an example, was able to retrieve the user's email address only if the user's email address was set to public on github. Passing the user:email scope had not effect when the email address was set to private. e.g.

provider = new firebase.auth.GithubAuthProvider();
provider.addScope('user:email');


来源:https://stackoverflow.com/questions/37618332/firebase-3-additional-auth-scope-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!