Enable cross-device authentication by scanning QR codes with mobile apps
A QR code displayed on a desktop or kiosk device.
qrCode.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
.
Initial state
qrCode.challenge()
, the QR code is ready to be scanned. Display it to the user.Claimed
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.Approved
onStateChange
is called with state: "approved"
and a token
, the user has approved the
challenge. Pass the token to your backend for validation.Rejected
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.
claimChallenge
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.
updateChallenge
method.
onStateChange
callback will return an accessToken
that should be passed to your backend to validate the challenge prior to completing the authentication flow.