
A QR code displayed on a desktop or kiosk device.
- Registering a mobile device for QR code authentication by adding a device credential. This step creates a new public/private key pair.
- To retrieve context about the challenge that the user is authorizing, and for anonymous challenges bind the user to the challenge by claiming the challenge.
- Responding to an authentication request by approving or rejecting a device challenge. This step uses the device’s private key to sign a message which is verified on the server using the public key.
Use cases
- Log into a desktop or web application from an application that is typically used on mobile
- Identify a user on a kiosk in a quick service restaurant (QSR) to load loyalty programs, rewards and offers
- Log into an application running on a TV
- Complete a payment via a terminal
Sequence diagram
The general flow for QR code authentication is as follows:- Generate a challenge
- Display the QR code to the user
- Wait for the user to scan and respond on their mobile device
- Handle the authentication result (approved/rejected)
Configure QR code auth in Authsignal Portal
Enable the Device credential authentication method for your tenant.Grab your Authsignal credentials
Head to Settings and grab your Tenant ID, API URL and API secret key. Add them as environment variables in your project:Implementing registration
1. Backend - Generate registration token
Track an action (e.g. “addAuthenticator”) to generate a short-lived token which can be used to authorize adding a new authentication method for a user.2. Mobile app - Add device credential
Use the token obtained in step 1 to register a new device credential in the app.Device registration should be implemented after login or when the app is launched in an
authenticated state. Registration tokens should only ever be generated for authenticated users in
order to ensure a strong binding between
authentication methods.
Implementing authentication
1. Backend - Track an action (optional)
You may optionally track an action from your backend if you want to create a QR code challenge that can only be completed by a specific user or run rules on the action for adaptive MFA. If you want to start a QR code challenge that can be claimed and completed by any user, skip to step 2. Track an action from your backend using our Server SDK or Server API.state
and token
to your frontend. On your frontend, check the state
parameter to conditionally challenge the user. If the state
is CHALLENGE_REQUIRED
, call the setToken
method to set the token.
When creating a QR code challenge after tracking an action, the custom data and action code must
be provided in the track request and cannot be overridden in the challenge request from the
frontend.
2. Frontend - Present a QR code
Use our Web SDK, Mobile SDKs or Client API to initiate a QR code challenge. Start a QR code challenge Use theqrCode.challenge()
method to initiate a challenge. The SDK will handle all the complexity of managing the challenge lifecycle, including automatic refreshing and state updates.
By default the SDK will use WebSocket connections. If your environment does not support WebSockets, you can fall back to polling using REST API calls by setting polling
to true
.
1
Initial state
After calling
qrCode.challenge()
, the QR code is ready to be scanned. Display it to the user.2
Claimed
When
onStateChange
is called with state: "claimed"
, the user has scanned the QR code. You
should blur or hide the QR code at this point to prevent others from scanning it.3
Approved
When
onStateChange
is called with state: "approved"
and a token
, the user has approved the
challenge. Pass the token to your backend for validation.4
Rejected
When
onStateChange
is called with state: "rejected"
, the user has declined the challenge. Show an error message and provide a way to retry.qrCode.refresh()
method:
qrCode.challenge()
method has been called. The original callbacks will be used with the new challenge.
3. Mobile App - Scan the QR code
Once the user scans the QR code, use the mobile sdkclaimChallenge
method to set the user attempting to complete the challenge.
The claimChallenge
method will return some context about the desktop or kiosk initiating the challenge such as ip address, location, user agent and custom data. This data can be shown to the user to help them decide if they want to approve or decline the challenge.
4. Mobile App - Approve or decline the challenge
Present a dialog to allow the user to review the challenge context and approve or decline the challenge by calling the mobile sdkupdateChallenge
method.
5. Backend - Validate the challenge
Once the challenge is approved, theonStateChange
callback will return an accessToken
that should be passed to your backend to validate the challenge prior to completing the authentication flow.
Next steps
- Passkeys - Offer the most secure and user-friendly passwordless authentication
- Push notification - Implement push notification authentication
- Trusted device - Implement trusted device authentication