Skip to main content

Start a QR code challenge

const { data } = await authsignal.qrCode.challenge({
  action: "kiosk-login",
  onStateChange: (state: ChallengeState, token?: string) => {
    if (state === "approved" && token) {
      // Validate the challenge on your backend
    }
  },
});

Parameters

action
string
required
The action being performed.
onStateChange
function
required
A function that is called when the challenge state changes.
onRefresh
function
A function that is called when the challenge should be refreshed.
custom
object
A JSON object which can include any key/value pairs. Can be used to provide additional context to the challenge which can be reviewed on the user’s mobile device.
refreshInterval
number
The interval in milliseconds at which the challenge should be refreshed. Defaults to 540000 (9 minutes). This should be set to a value lower than your token’s expiry time to allow a tolerance for the challenge to be completed.
polling
boolean
Whether to poll for the challenge result using RESTful API endpoints. Should only be used if you are unable to use WebSocket connections.Defaults to false and uses WebSockets.
pollingInterval
number
The interval in milliseconds at which the challenge should be polled.Only relevant is polling is set to true.

Response

response
AuthsignalResponse<QrCodeChallengeResponse>
data
QrCodeChallengeResponse

Refresh a QR code challenge

await authsignal.qrCode.refresh();
This can only be called after a QR code challenge has been initiated. The callback functions passed to the challenge method will be re-used.

Parameters

custom
object
A JSON object which can include any key/value pairs. Can be used to update context to the challenge which can be reviewed on the user’s mobile device.