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?
2
Answers
As far as I know, the screen name you are looking for is not included as part of the Twitter OAuth provided through Firebase, but the
uid
that you have found is indeed the user’s twitter user ID.Using this ID you can use the Twitter API to get details about the user by passing it to the twitter API users/show endpoint. Since you plan on providing Twitter based communication, you will likely need to use this API anyway.
e.g.:
You can actually get it immediately after sign-in, via AdditionalUserInfo.
Here is an example with the web API: