/v2/users/inquiryUserInfo

POST /v2/users/inquiryUserInfo

With this API call, a merchant can inquire about user information with the access token. The specific information to query is defined by the scopes of the authorization code you obtained by calling the my.getAuthCode JSAPI.

Structure

A message consists of a header and body. The following sections are focused on the body structure. For the header structure, see:

Request parameters

Field

Data type

Required

Description

Example

appId

String

Yes

Indicates the unique ID assigned by Mini Program Platform to identify a mini program.

  • Maximum length: 32 characters
  • Characters not allowed: special characters such as @ # ?

Note: Obtain this field via the my.getAppIdSync JSAPI or Mini Program Platform.

"3333010071465913xxx"

accessToken

String

Yes

The access token is used to access user information. For the specific information that can be accessed, see the my.getAuthCode JSAPI.

  • Maximum length: 128 characters
  • Characters not allowed: special characters such as @ # ?

Note: Obtain this field via the /v2/authorizations/applyToken API.

"281010033AB2F588D14B43238637264FCA5AAF35xxxx"

authClientId

String

Yes

Indicates the unique ID assigned by the super app to identify an authorized merchant.

  • Maximum length: 128 characters
  • Characters not allowed: special characters such as @ # ?

"202016726873874774774xxxx"

Response parameters

Field

Data type

Required

Description

Example

result

Result

Yes

Indicates the request result such as status and error codes.

{

"resultCode":"SUCCESS",

"resultStatus":"S",

"resultMessage":"success"

}

userInfo

User

No

Indicates the user information that the merchant queried.

Note:

  • This parameter must be returned when the request is successful (that is, the value of result.resultStatus is S.)
  • The result of user information is decided by the scopes that used to create, so any field on the userInfo my be null.

See Response sample for details.

Result process logic

In the response, the result.resultStatus field indicates the result of processing a request. The following table describes each result status:

Result status

Description

S

The inquiry is successful.

Use the accessToken to access user information within the corresponding scope.

The corresponding result.resultCode is SUCCESS and the result.resultMessage is Success.

U

The status of the inquiry is unknown.

The corresponding result.resultCode is UNKNOWN_EXCEPTION and result.resultMessage is "An API calling is failed, which is caused by unknown reasons.". For details, see the Common error codes section.

F

The inquiry is failed.

The corresponding result.resultCode and result.resultMessage are various based on different situations. For details, see the following Error codes section.

Error codes

Error codes are usually classified into the following categories:

  • Common error codes are common for all mini program OpenAPIs in V2.
  • API-specific error codes: are listed in the following table.

Error code

Result status

Error message

Further action

INVALID_AUTH_CLIENT

F

Either the merchant does not exist or the merchant does not onboard to the native app.

Use a valid authClientId assigned by the super app.

INVALID_ACCESS_TOKEN

F

The access token is not valid.

Obtain a new authorization code via the my.getAuthCode JSAPI and then get a valid access token with the authorization code via the /v2/authorizations/applyToken API.

EXPIRED_ACCESS_TOKEN

F

The access token is expired.

Obtain a new access token with a refresh token via the /v2/authorizations/applyToken API.

Samples

The data flow of inquiring about a user's information is illustrated as below:

image.png

  1. The merchant server calls this API with the access token to inquire about the user's information.
  2. The super app server returns the user's information to the merchant server based on the scopes of the access token.

Request

copy
{
  "appId": "3333010071465913xxx",
  "accessToken": "281010033AB2F588D14B43238637264FCA5AAF35xxxx",
  "authClientId": "202016726873874774774xxxx"
  
}

The merchant (202016726873874774774xxxx) uses the access token (281010033AB2F588D14B43238637264FCA5AAF35xxxx) to access the user's specific information.

Response

copy
{
  "result": {
    "resultCode": "SUCCESS",
    "resultStatus": "S",
    "resultMessage": "success"
  },
  "userInfo": {
    "userId": "2043",
    "phoneNumber": "57991642756",
    "email": "jmarquezxx@trust.lat",
    "documentType": "Passport",
    "documentNo": "185924300",
    "name": "Jams",
    "surname": "Zhang",
    "deliveryAddress": null,
    "extendInfo": {
      "access_token":"dJflShMZsv1AYhttHPwUBIcPT9mX7Q-2-ntySzp2vdo.w-YJdI3PCv1vPyCxu1VPxoQRqtxdrXWS4pGKqs2_ni8",
      "id_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6InB1YmxpYzozODYwNGE2Zi01NDYxLTRlNDEtYTEzYS0xNWU4ZTE5YzBjNTAifQ.eyJhdF9oYXNoIjoiRU8tUTdoWW5lbXBxRWlqdjIxUDZ1ZyIsImF1ZCI6WyJjYzM3MmMxYS1mNjdkLTRiOTYtOGRhNy1jNjU1NzgzODkzNTUiXSwiYXV0aF90aW1lIjoxNjQ5OTY0NDIxLCJkbmkiOiIxODU5MjQzMDAiLCJlbWFpbCI6ImptYXJxdWV6QHRydXN0Lmxh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FYo5KsR3KbG-eUvOpmz-3sUroKSkqPwI2tfHzzUTfkZXNeJJXfIxlhXjTZ8OCA"
    },
    "deviceName": "myPhone",
    "brand": "iphone",
    "os": "test",
    "osVersion": "v1.0.0",
    "claroPay": {
      "cpAccessToken": "ee8641a8-b633-4bb1-b70d-fee2319dca8e",
      "availableBalance": "120.00"
    }
  }
}
  • result.resultStatus is S, which means the inquiry request is successful.
  • userInfo describes the user's information you get via the inquiryUserInfo API. The information includes userId, status, nickName, userName, avatar, gender, birthDate, nationality, loginIdInfos, contactInfos, and extendInfo.

Related links

my.getAuthCode

my.getAppIdSync

/v2/authorizations/applyToken