Skip to main content

QR Authentication

This document describes how to utilize QR authentication in the BSA-JS

Function Description#

QR Authentication can be used via mobile devices without an ID by following the steps below.
First, create a QR code implemented by bsa.js and then click QR Authentication on the main screen of BSA app to activate the QR Scanner.

QR Authentication Request#

When authentication is requested, API calls are made with requestQrCallback().
Upon the request of QR authentication, a QR code will be created on the <canvas/> tag that has been set up with Guardian-JS. The result will be returned with onSuccess if successfully authenticated.

requestQrCallback(qrCanvas, successCallback, errCallback)

Parameter#

NameTypeDescription
qrCanvasElement<canvas/> element to create BSA QR code

Example#

const bsa = new BSA("{Client Key}");bsa.requestQrCallback(qrCanvas, (data) => {  console.log('onSuccess');  console.log('accessToken : ', data.accessToken);  console.log('refreshToken : ', data.refreshToken);}, (errorCode, errorMsg) => {  console.log('onError');  console.log('errorCode : ', errorCode);  console.log('errorCode : ', errorMsg);});

onSuccess#

KeyTypeDescription
accessTokenStringAccess Token
refreshTokenStringRefresh Token

The token will be returned if authentication succeeds, and it can be utilized for the BSA authentication.

onError#

KeyTypeDescription
errorCodeIntError code
errorMsgStringError message

If authentication fails, the error code and error message will be returned.
Possible error codes are as follows.

ErrorCodeDescriptionSolution
2000Invalid client keyCheck the client key
2008Unregistered userCheck BSA sign in status
3201Not properly linked clientAfter signing up for BSA, go through Menu => My BSA => Trusted Website => Site Link and connect with the client website
5001Authentication timeoutMake request for authentication once again, because previous authentication is no longer valid
5005Unauthorized userContact the person in charge to solve this matter
5006Temporarily suspended userContact the person in charge to solve this matter
5007Permanently suspended userContact the person in charge to solve this matter
5008Withdrawn userUser accounts can be reactivated within certain period of time by reactivation
2010User authentication in-progressDepending on the circumstances, cancel previous authentication and request for new one
5011User authentication canceledMake request for re-authentication
5015Failed to create channelIt can occur when the parameters are not enough
If it happens constantly, please inquire the person in charge
5017Failed to send push notificationProblems have occurred with the FCM(Firebase Cloud Messaging), etc.
If it happens constantly, please inquire the person in charge
5022Verification failureNode verification failed
If it happens constantly, please inquire the person in charge
5023Invalid QR IDIt can occur when the authentication has expired. In this case, re-authentication should be requested
5024Invalid QR URL CLIENTIt can occur when the QR code was scanned through another app other than BSA. It must be scanned by BSA app only

Cancel QR Authentication#

Authentication in progress will be canceled if requested. Users can request for authentication again any time.
If the cancel request is successful, 5011 errorCode will be returned. More in detail can be found in the onError

onQrCancel(qrCanvas, errCallback)

Parameter#

NameTypeDescription
qrCanvasElement<canvas/> element to create BSA QR code

Example#

<div>  <canvas /></div>
const bsa = new BSA("{Client Key}");bsa.onQrCancel(qrCanvas, (errorCode, errorMsg) => {    console.log('onError');    console.log('errorCode : ', errorCode);    console.log('errorCode : ', errorMsg);});

onError#

KeyTypeDescription
errorCodeIntError code
errorMsgStringError message

If cancel request fails, the error code and error message will be returned.
Possible error codes are like below.

ErrorCodeDescriptionSolution
3100Unregistered userCheck the user key requested
5019No authentication in progressAuthentication has been already canceled, or not in progress now

Set QR Authentication Timer#

Add callback function to check valid BSA QR Authentication time.
The remaining time for authentication will be displayed and if expired, the user should request for authentication again.

setQrTimer(onCallBack)

Parameter#

  • none

Example#

const bsa = new BSA("{Client Key}");bsa.setQrTimer((time) => {  console.log('onTime');  console.log('time : ' + time);});

onTime#

KeyValueDescription
timeIntValid authentication time

Valid authentication time will be returned as the result of a callback function.


Set QR Authentication Status#

Add callback function to check BSA authentication status.
It is possible to see the authentication status during the whole process from authentication request to the final authentication.

setQrMessage(onCallBack)

Parameter#

  • none

Example#

const bsa = new BSA("{Client Key}");bsa.setQrMessage((message) => {  console.log('onMessage');  console.log('AuthStatus : ' + message);});

onMessage#

KeyValueDescription
messageStringAuthentication status

Authentication status will be returned as the result of a callback function.