How to get user's username and logo from the auth provider?
Hi there,
Is there a way for me to get user's user name and logo from such as Facebook? I can log the user in successfully through Facebook login, and can get the current uid from auth.
How can I get info such as login email address, username, and user logo?
Thanks!
You can config something like:
firebaseAuthConfig({ provider: AuthProviders.Facebook, method: AuthMethods.OAuthToken, remember: 'default', scope: ['email','id','name','picture'] })
You can change whatever method your are using popup or redirects etc. These scope values you can choose from facebook login api options based on what all values you want to pull from Facebook: https://developers.facebook.com/docs/facebook-login/permissions
Hope this helps!!
@amity203 Thank you for your reply.
Could you show me how to get those values like email, id, name and picture? I'm new to the frameworks and don't know how to write it in code.
I notice you have Ionic projects, I'm also using Ionic2 with AngularFire2.
Thanks a lot!!
@joyceview Surely, I will try to find out some time this week or may be weekend to prepare an example of that.
@amity203 Thank you, much appreciated!
I just saw from Issue #39
`@Component({
template:<h1>Welcome, {{ user.github.username }}</h1>
})
class Login { constructor(private af:AngularFire, private user: FirebaseUser) { } }`
But I'd like to have the value at the ts file, and will be able to decide which node to save in db.
Seems like this is a way to go. Still need to dig in more.
You can use like below to get details in ts file: constructor( public af: AngularFire) { } this.af.auth.subscribe(user => { if(user) { // user logged in this.user = user; } else { // user not logged in this.user = {}; } });
Also you can fetch other as well, see this example for facebook authentication: https://github.com/aaronksaunders/basicaf2 rest i will also make an Ionic 2 and angularfire2 example soon
I understand that auth.login became auth.signInWithEmailAndPassword and so on - what does .auth.subscribe(user => become, it won't accept subscribe
@dovk This is a closed issue. If you're experiencing a bug please create a new issue. For general how-to type questions, please use StackOverflow.