Get user information
This page instructs you how to get information about the user that is currently logged in. There are two main ways to do so.
- The user must be logged into your application via Passport
Getting user information via API
There is a getUserInfo API that can be used with the users access token. It will return the following:
Property | Description |
---|---|
sub | The subject (unique identifier) of the logged-in user. |
email 1 | The email address of the logged-in user. This property will be undefined if the email scope has not been requested. |
passportAddress | The Passport address of the logged-in user (if they've been registered). |
linkedAddresses | The external wallets the user has linked to their Passport account via the Dashboard. |
Getting user information via Typescript SDK
The getUserInfo
function on the Passport instance returns a promise that resolves with the following information about
the currently logged-in user:
const userProfile = await passportInstance.getUserInfo();
Property | Description |
---|---|
email 1 | The email address of the logged-in user. This property will be undefined if the email scope has not been requested. |
sub | The subject (unique identifier) of the logged-in user. |
nickname | The nickname of the logged-in user. |
Note that the getUserInfo
function may throw the following error:
Error Code | Cause | Resolution |
---|---|---|
NOT_LOGGED_IN_ERROR | No user is logged in at the time of the function call. | Verify that a user has logged in before attempting to call getUserInfo |
The user's linked addresses can also be retrieved from the Typescript SDK like so:
const linkedAddresses = await passportInstance.getLinkedAddresses();
1 Apple Social Login Email Masking Restrictions:
Partners implementing the Apple Social Login within Passport should note a potential restriction regarding the user's email address. If a user chooses to mask their email address, the email address return will appear as xyz@privaterelay.appleid.com
. A masked email prevents partners from directly emailing users. Partners must consider this limitation while interacting with users who have enabled email masking through Apple Social Login. For any further inquiries or assistance, please get in touch with our dedicated support team.