Hello i want to get a profile Url from the Firebase OAuth response, currently firebase give this about the profile :
displayName, email, photoURL, uid
Have you any idea if its possible ?
(I work with a serverless project)
Hello i want to get a profile Url from the Firebase OAuth response, currently firebase give this about the profile :
displayName, email, photoURL, uid
Have you any idea if its possible ?
(I work with a serverless project)
You will get additional user info when the sign in attempt resolves:
firebase.auth().signInWithPopup(new firebase.auth.TwitterAuthProvider())
.then(function(userCredential) {
// All additional user info is available here.
console.log(userCredential.additionalUserInfo.profile);
})
.catch(function(error) {
// Error occurred.
});
For more on this, check firebase.auth.UserCredential
.
I needed to do this from Node, however, Google/Firebase Auth does not store a user's Twitter handle (at least it's not accessible through firebase-admin
).
However, they do make the Twitter uid accessible as the question points out. With that, you can subsequently call Twitter's API to get a user by their uid and the result will return the handle:
import { TwitterApi } from 'twitter-api-v2';
const BEARER = process.env['TWITTER_BEARER_TOKEN'] as string;
const logTwitterHandleFromUid = async (): Promise<void> => {
// UID for https://twitter.com/StackOverflow
const details = await new TwitterApi(BEARER).v2.user('796800233011298304');
// pull out the Twitter handle
const twitter_handle = details.data.username;
return console.log(twitter_handle);
};