2

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)

3
  • is this helpful? firebase.google.com/docs/auth/web/…
    – GrafiCode
    Aug 9, 2018 at 16:25
  • It's just those four fields in the Twitter providerData object, there's nothing extra?
    – Rup
    Aug 10, 2018 at 7:50
  • @Rup no, only the same data that i already have
    – AlexDemzz
    Aug 10, 2018 at 14:32

2 Answers 2

3

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.

1
  • Perfect, it return the screen name and id, i can now create the profile url !
    – AlexDemzz
    Aug 13, 2018 at 14:14
1

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);
};

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.