Get user information

Get user information

This page instructs you how to get information about the user that is currently logged in.

Pre-requisites

  • The user must be logged into your application via Passport

Getting user information

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 passport.getUserInfo();
PropertyDescription

email1

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

This value will always be undefined for the time being.

Note that the getUserInfo function may throw the following error:

Error CodeCauseResolution

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

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.

Last updated