Skip to main content

Authenticate using Portkey QR Code

You can let your users authenticate with Portkey using their Portkey Mobile App to scan the QR code generated by using the Portkey SDK for sign-in flow.

This is available on all platforms.

Access the PortkeySDK.AuthService

The AuthService class is the entry point for all authentication API calls. It is accessible through PortkeySDK.AuthService.

IAuthService auth = PortkeySDK.AuthService;

Authenticate with PortkeySDK

  1. Generate a QR code for the user to login through LoginWithQRCode from AuthService.
// DisplayQRCode is a function that takes in a Texture2D and displays the QR code Texture2D on screen for the user to scan.
// mySuccessCallback will be called when the user successfully authenticated.
StartCoroutine(PortkeySDK.AuthService.LoginWithQRCode(DisplayQRCode, mySuccessCallback));
  1. You may choose to cancel the QR code login anytime by calling CancelLoginWithQRCode from AuthMessage.
// this will cancel the login flow for logging in with QR code when it is still authenticating the user.
PortkeySDK.AuthService.Message.CancelLoginWithQRCode();

Next Steps

After the user has signed up or logged in, a DIDAccountInfo will be returned that corresponds to the Portkey account that was used when scanning the QR code to login. DIDAccountInfo contains signing key and account information that can be used to get a user's account balance and sign transactions.

Sign out

To sign out a user, call Logout.

StartCoroutine(PortkeySDK.AuthService.Logout());