Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Auth: Is it possible to see user's Twitter ID?

I have just implemented the Twitter login to my Firebase web app. When the user successfully login, I'd like to see the user's Twitter ID (to enable Twitter-based communication among users).

According to the document (https://firebase.google.com/docs/auth/web/manage-users), the provider specific information is under providerData of the user info.

Under the providerData, I see the following

displayName: "Satoshi Nakajima" (as I expected)
email: null (as I expected)
phoneNumber: null (as I expected)
photoURL: "https://abs.twimg.com/..." (as I expected) 
providerId: "twitter.com" (of course)
uid: "1129128..." (what is this?)

The uid seems like a unique id, but it is different from the Twitter ID we usually use, such as @snakajime (which is mine).

I am wondering why I don't see the Twitter id here. Am I missing something? Is there any API to get the Twitter ID from this strange uid?

like image 222
Satoshi Nakajima Avatar asked May 16 '19 22:05

Satoshi Nakajima


People also ask

How can I get user details from Firebase?

If the user login with a custom "email/password" you don't know anything else about that user (apart from the unique user id). If a user login with Facebook, or with Google sign in, you can get other information like the profile picture url. It is explained here: firebase.google.com/docs/auth/android/… .

Does firebase Auth store user data?

Firebase users have a fixed set of basic properties—a unique ID, a primary email address, a name and a photo URL—stored in the project's user database, that can be updated by the user (iOS, Android, web).

Can we see user password in firebase?

If you are u storing the user and password in firebase authentication then no it is not possible to view the password written by the user. You can store the password in the database but if someone got access to your database they can know all the passwords of the users using your application.


1 Answers

You can actually get it immediately after sign-in, via AdditionalUserInfo.

Here is an example with the web API:

firebase.auth().signInWithPopup(new firebase.auth.TwitterAuthProvider())
  .then((userCredential) => {
    // Get the Twitter screen name.
    console.log(userCredential.additionalUserInfo.username);
  })
  .catch((error) => {
    // An error occurred.
  });
like image 185
bojeil Avatar answered Sep 30 '22 23:09

bojeil