Login with Passport
Log into Passport
The player will not have a wallet until the ZkEvmRequestAccounts
function is called. Developers should call this function if they want to create a wallet for the player after logging into Passport.
For more details on authenticating users without a wallet, see the Authenticating users without wallet section.
To log the gamer into Passport:
await passport.Login();
This opens a window on desktop or an in-app browser on mobile devices, guiding gamers through the auth flow.
Direct Login Methods
For a more streamlined user experience, you can use direct login methods to bypass the provider selection page and redirect users directly to their preferred authentication provider (Apple, Google, or Facebook).
Quick example:
// Login directly with Apple
await passport.Login(directLoginMethod: DirectLoginMethod.Apple);
// Login directly with Google
await passport.Login(directLoginMethod: DirectLoginMethod.Google);
// Login directly with Facebook
await passport.Login(directLoginMethod: DirectLoginMethod.Facebook);
Stored Credentials
Once the gamer is connected to Passport, the SDK will store your credentials (access, ID, and refresh tokens).
You may use Login(useCachedSession: true)
to re-login the gamer to Passport using the saved credentials. However, if this fails, it will not automatically prompt the user to re-login again.
bool hasCredsSaved = await passport.HasCredentialsSaved();
if (hasCredsSaved)
{
await passport.Login(useCachedSession: true);
// Successfully re-logged into Passport
}