angularfire icon indicating copy to clipboard operation
angularfire copied to clipboard

How to get user's username and logo from the auth provider?

Open joyceview opened this issue 10 years ago • 7 comments

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!

joyceview avatar Aug 14 '16 01:08 joyceview

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 avatar Aug 14 '16 05:08 amity203

@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 avatar Aug 16 '16 08:08 joyceview

@joyceview Surely, I will try to find out some time this week or may be weekend to prepare an example of that.

amity203 avatar Aug 16 '16 09:08 amity203

@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.

joyceview avatar Aug 16 '16 23:08 joyceview

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

amity203 avatar Aug 17 '16 00:08 amity203

I understand that auth.login became auth.signInWithEmailAndPassword and so on - what does .auth.subscribe(user => become, it won't accept subscribe

dovk avatar Jun 01 '17 15:06 dovk

@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.

markgoho avatar Jun 01 '17 16:06 markgoho