In earlier firebase versions[https://www.firebase.com/docs/web/guide/login/facebook.html] there is a way to retrieve Facebook(or other provider) specific data, such as _facebook.accessToken; facebook.id_, through authdata object.
Even for current firebase version [https://firebase.google.com/docs/auth/web/facebook-login], var token = result.credential.accessToken; can retrieve providers oAuthToken (if not any other information?)
So for Firebae-UI
Example use case to elaborate why it is required:
Hi @jalajc,
The signInSuccess callback returns the credential as the second parameter, when a provider like Facebook has been used for sign-in. See the section concerning this: https://github.com/firebase/firebaseui-web#available-callbacks
You can then retrieve the accessToken from this object.
Is that what you're looking for?
@TMSCH not exactly, may be because only one call back is provided currently. that doesn't solve things for me.
Consider another case: My app want to post a status to user's Google plus feed and Facebook feed. Therefore while login using firebaseUI, App also requests the scope/permission to access and write feeds/post. User gives permission. Login is successful. Callback _credential_ is received and stored. However oAuth token is also returned by facebook/googleplus oAuth identity provider.Also user's unique identity in facebook system (may be in google too) is also returned (not the uid of firebase) by oAuth provider. But these parameters are not visible in signinsuccess callback; leaving me clueless if I have to post to user's feed in future how I will do.
While the older version of firebase[https://www.firebase.com/docs/web/guide/login/facebook.html] gave access to some key callback parameters such as facebook.id, I don't see that in firebase.js/firebase-ui docs.
If I understand correctly, you only need the Facebook uid and the credential, is that right? You can access it in the providerData attribute of the User instance. It contains a list of provider's data, with the user's uid of the provider.
Example:
signInSuccess: function(user, credential) {
var facebookUid;
for (var providerInfo of user.providerData) {
if (providerInfo.providerId == 'facebook.com') {
facebookUid = providerInfo.uid;
}
}
}
Does that solve your issue?
@TMSCH (Sorry mate, wasn't possible to reply earlier)
Thanks. :+1: Yups thats what I was looking. With this specific snippet I see what you were inferring to earlier. I also figured out decoding token from accessToken (with all those public key thing ;) ) :
user.getToken().then(function(accessToken) {
document.getElementById('account-details').textContent = JSON.stringify({
displayName: displayName,
email: email,
emailVerified: emailVerified,
photoURL: photoURL,
uid: uid, /*facebook Id*/
accessToken: accessToken,
providerData: providerData
}, null, ' ');
});
My bad, I didn't understood it first time, may be I was perplexed in the documentation.
@bojeil-google also answered me here. Thanks! :)