Skip to content

List of complete interfaces for APP code scanning login

GenAuth provides a REST-based code scanning login interface that developers can call directly.

Generate QR code

POSThttps://core.genauth.ai/api/qrcode/gene

This interface will return the QR code ID (random) and QR code link.

Headers

NameTypeDescription
x-authing-userpool-idREQUIREDstring

User pool ID

Body Parameters

NameTypeDescription
customeDataOPTIONALstring

Custom data field, which will be written into the original data of the QR code.

sceneREQUIREDstring

Scene value. It is a constant value, fill in APP_AUTH.

Response

200: OK

Field explanation:

  • random: QR code unique mark, used for querying QR code status and user confirmation authorization interface.
  • url: QR code image address.
  • expiresIn: QR code validity period.
json
{
  "code": 200,
  "data": {
    "random": "SzZrszCJNCFfVBDUCKLDtAYNBR96SK",
    "expiresIn": 120,
    "url": "https://files.authing.co/user-contentsqrcode/5fae2648201cfd526f0ec354/SzZrszCJNCFfVBDUCKLDtAYNBR96SK.png"
  }
}

Generated QR code example:

使用在线二维码解码工具 查看二维码数据如下:

json
{
  "scene": "APP_AUTH",
  "random": "SzZrszCJNCFfVBDUCKLDtAYNBR96SK",
  "userPoolId": "5fae2648201cfd526f0ec354",
  "createdAt": "2020-11-13T06:23:25.396Z",
  "expiresIn": 120,
  "customData": {}
}

Query QR code status

GEThttps://core.genauth.ai/api/qrcode/check

Query Parameters

NameTypeDescription
randomREQUIREDstring

QR code ID.

Response

200: OK
json
{
  "code": 200,
  "message": "Query QR code status successfully!",
  "data": {
    "random": "SzZrszCJNCFfVBDUCKLDtAYNBR96SK",
    "userInfo": {},
    "status": 0,
    "ticket": null,
    "scannedUserId": null
  }
}

Request result field description:

  • status
    • 0: Not scanned.
    • 1: Scanned but the user has not clicked to agree to authorization or cancel authorization. At this time, the user's avatar and nickname will be returned, but no other confidential information will be included. It can be used for front-end avatar display.
    • 2: User agrees to authorization
    • 3: User cancels authorization
    • -1: Expired
  • userInfo:
    • By default, after the user scans the code, the nickname and avatar fields will be included
    • Developers can also configure the return of complete user information (including login credentials token)
  • ticket: used to exchange for complete user information. **This field will only appear after the user agrees to authorization. **See below for details.

Use ticket to exchange for user information

POSThttps://core.genauth.ai/api/qrcode/userinfo

Body Parameters

NameTypeDescription
ticketREQUIREDstring

Ticket returned by the query QR code status interface

Response

200: OK
json
{
  "code": 200,
  "message": "Exchange for user information successfully",
  "data": {
    "id": "5e05bbf2d51b3761d5c71070",
    "email": "983132@qq.com",
    "emailVerified": false,
    "oauth": "",
    "username": "983132@qq.com",
    "nickname": "",
    "company": "",
    "photo": "https://usercontents.authing.co/authing-avatar.png",
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7ImVtYWlsIjoiOTgzMTMyQHFxLmNvbSIsImlxxxxxxxxx",
    "phone": "",
    "tokenExpiredAt": "2020-01-11T08:08:18.000Z",
    "loginsCount": 1,
    "lastIp": "::1",
    "signedUp": "2019-12-27T08:08:18.115Z",
    "blocked": false,
    "isDeleted": false
  }
}

INFO

Note: By default, this interface is only allowed to be called on the server side, that is, after initialization with the user pool key.

The default validity period of the ticket is 300 seconds.

Developers can modify it in the GenAuth console Basic Configuration -> Basic Settings -> App Scan Code Login Web Custom Configuration. **For details, see Custom Configuration Item Page. **

APP-side mark scanned code

POSThttps://core.genauth.ai/api/qrcode/scanned

The APP side marks that the code has been scanned. After marking the code scanned, the web side will be able to obtain the nickname and avatar of the current user.

Headers

NameTypeDescription
x-authing-userpool-idREQUIREDstring

User pool ID

AuthorizationREQUIREDstring

User login credentials.

Body Parameters

NameTypeDescription
randomREQUIREDstring

QR code ID.

Response

200: OK
js
{
    code: 200,
    message: "QR code scanning confirmed successfully",
    data: {
        random: "", // Return as is
        status: 0,
        description: "xxxx",
    }
}

INFO

The APP needs to meet two conditions:

  1. The user must be logged in
  2. The user's user pool ID matches the QR code user pool ID.

APP side agrees to authorization

POSThttps://core.genauth.ai/api/qrcode/confirm

APP side agrees to authorization. Before calling this interface, you need to call the scanned interface first.

Headers

NameTypeDescription
x-authing-userpool-idREQUIREDstring

User pool ID

AuthorizationREQUIREDstring

User login credentials.

Body Parameters

NameTypeDescription
randomREQUIREDstring

QR code ID

Response

200: OK
js
{
    code: 200,
    message: "Authorization login successful",
    data: {
        random: "", // Return as is
        status: 1,
        description: "xxxx",
    }
}

INFO

The APP needs to meet two conditions:

  1. The user must be logged in
  2. The user's user pool ID matches the QR code user pool ID.

Cancel authorization on the APP

POSThttps://core.genauth.ai/api/qrcode/cancel

App end cancels authorization. Before calling this interface, you need to call the scanned interface first.

Headers

NameTypeDescription
x-authing-userpool-idREQUIREDstring

User pool ID

AuthorizationREQUIREDstring

User login credentials.

Body Parameters

NameTypeDescription
randomREQUIREDstring

QR code ID

Response

200: OK
js
{
    code: 200,
    message: "Cancel authorization successfully",
    data: {
        random: "", // Return as is
        status: -1,
        description: "xxxx",
    }
}

INFO

The APP needs to meet two conditions:

  1. The user must be logged in
  2. The user's user pool ID matches the QR code user pool ID.

Agent infrastructure for identity, memory, and web action.