Unfortunately the user’s screen name is not presented in the JSON data. Sync user attributes at each login is toggled on. Using session.userinfo.screen_name retrieves nothing.
So, specifically, how can I acquire the logged-in user’s Twitter handle?
May I please get a reply on this subject? I had the exact same issue one year ago and quit, only to pick it up again now.
I have downloaded the sample Python code which Auth0 provides. I have successfully connected my Twitter app to Auth0. I can login to my website using my Twitter account without failure. The sync user attributes at each login is toggled on.
In my original post I shared with you all of the data which is presented to me upon logging in. The name and nickname variables are exactly the same. My Twitter handle is nowhere to be found in the provided JSON data. When I go to my HTML template and add the Jinja code {{session.userinfo.screen_name}} into an h1 element, nothing appears on the page. The same is true when I write {{session.user.screen_name}}, {{session.screen_name}}, and {{screen_name}}.
How can this possibly be so difficult? I am aware that I may be missing something, but I would really appreciate an answer because I feel like I have done everything right.
I am a super noob, though. Does this mean I will have to manually insert the user’s ID into this endpoint documentation thing you referenced just to retrieve their Twitter handle? How can I achieve this automatically? Why isn’t the Twitter handle provided in the user info JSON dump that is displayed on the screen upon logging in?
Do you have any sources you could point me to in order to help me better understand? I just want the Twitter handle displayed on the Flask template after the user logs in.
I don’t get why the sample code which Auth0 provides can display everything but the user’s Twitter handle.
Yes, that’s correct. You must supply the user_id to the Get a user endpoint to use it correctly. Once you make this request, the user’s profile is returned in the response, giving you the user’s Twitter screen name.
The user’s Twitter handle is a social identity provider basic attribute:
Ok, thank you. I’ll try to write a script which automatically detects the user’s id then calls the API to then display their Twitter handle on the page.
Regarding the last sentence I wrote in the part of my reply you referenced, I know the basic profile button calls for the Twitter handle, but I don’t know why I have to manually write a script to get the Twitter handle when there is a lot of information that is already provided.
Here’s a screenshot of what I see when I login to my Flask website:
According to your screenshot, it looks like it’s returning information about your session. This includes your access token, ID token, and information derived from decoding the access token (expires_at, expires_in, scope), along with the "userinfo" section. The “userinfo” section comes from using the access token against the /userinfo endpoint of the Authentication API.
Essentially, the information displayed on that page does not have any details about the user’s full profile. As a result, you would need to write a script to get the Twitter screen name of the user.