Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase 3 - Additional Auth Scope Data

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,

like image 204
Tony Avatar asked Nov 09 '22 14:11

Tony


2 Answers

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.

like image 126
bojeil Avatar answered Dec 01 '22 21:12

bojeil


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');
like image 30
Charl Kruger Avatar answered Dec 01 '22 21:12

Charl Kruger