get first name and last name from google
# support-questions
t
If I execute ThirdPartyEmailPassword.getUserById, how can I get the first and last name of the user?
r
You can inspect the user object returned from the
getUserById
function call to tell you which login method was used. If the user object contains a
thirdParty
property, then they used social login, else email password. If they used social login, you will need to use the access token to query the provider's API to get the user's first and last name. You can obtain the user's first and last name by using the access token to query Google's API. You can follow the steps outlined in the Supertokens documentation for getting the provider access token from Google (https://supertokens.com/docs/thirdpartyemailpassword/common-customizations/getting-provider-access-token). Once you have the access token, you can use it to query Google's People API to get the user's profile information, including their first and last name. You can find more information on how to use the People API to get profile information here: https://developers.google.com/people/api/rest/v1/people/get.
st-bot-test-case
4 Views