my.getAuthCode prompts the Mini Program user to authorize access and returns an authCode. Merchants exchange this code for access tokens to retrieve user identifiers and profile data. For scope definitions and token exchange, refer to User authorization.
my.getAuthCode({
scopes: ['auth_base'],
success: (res) => {
my.alert({
content: res.authCode
});
},
fail: (err) => {
console.log(err.authErrorScopes);
}
});
| Property | Type | Required | Description |
|---|---|---|---|
scopes | Array<string> | Yes | Authorization scopes to request. See Scope reference. |
success | Function | No | Callback executed on success. Receives the payload described in Callback payload. |
fail | Function | No | Callback executed on failure. Receives the payload described in Callback payload. |
complete | Function | No | Callback executed on completion, regardless of outcome. |
| Scope | Description | Silent authorization |
|---|---|---|
auth_base | Obtain the unique user ID. | Yes |
USER_ID | Obtain the unique user ID. | Yes |
USER_LOGIN_ID | Obtain the user login ID. | Yes |
HASH_LOGIN_ID | Obtain the hashed user login ID. | Yes |
auth_user | Obtain the user's basic profile information. | No |
USER_NAME | Obtain the user's name. | No |
USER_AVATAR | Obtain the user's avatar. | No |
USER_GENDER | Obtain the user's gender. | No |
USER_BIRTHDAY | Obtain the user's birthday. | No |
USER_NATIONALITY | Obtain the user's nationality. | No |
USER_CONTACTINFO | Obtain the user's contact information. | No |
NOTIFICATION_INBOX | Send notifications to the user's in-app inbox. | No |
AGREEMENT_PAY | Enable auto-debit payments from the user's balance or card. | No |
CARD_LIST | Access the user's linked bank card information (high permission scope). Required by inquiryUserCardList. | No |
ACCOUNT_LIST | Access the user's bank account list (account numbers only, without sensitive card information). Required by inquiryUserAccountList. | No |
auth_basesupports silent authorization and does not interrupt the user. All other scopes require proactive user consent.
| Scope | Description | Silent authorization |
|---|---|---|
auth_base | Obtain the unique merchant ID. | Yes |
MERCHANT_ID | Obtain the unique merchant ID in Super Qi. | Yes |
MERCHANT_NAME | Obtain the merchant's business name. | No |
MERCHANT_LOGO | Obtain the merchant's logo. | No |
AGREEMENT_PAY | Enable auto-debit payments from the merchant's balance or card. | No |
NOTIFICATION_PUSH | Send push notifications to the merchant. | No |
NOTIFICATION_INBOX | Send notifications to the merchant's in-app inbox. | No |
NOTIFICATION_WhatsApp | Send WhatsApp notifications to the merchant. | No |
CARD_LIST | Access the merchant's linked bank card information (high permission scope). | No |
Scopes with silent authorization do not require explicit merchant approval. All other scopes require the merchant to grant consent.
| Property | Type | Required | Description |
|---|---|---|---|
authCode | string | Yes | Authorization code to exchange via applyToken. |
authErrorScopes | Record<string, string> | No | Map of scopes that failed with associated error codes. |
authSuccessScopes | string[] | No | List of scopes that were successfully authorized. |
{
"authCode": "0000000001T1dc0W0tv44B0BD00007826"
}
{
"authErrorScopes": {
"auth_user": "10001"
}
}
| Code | Description |
|---|---|
3 | ERROR_CODE_UNKNOWN_ERROR |
1000 | ERROR_CODE_UNKNOWN_ERROR |
1001 | ERROR_CODE_USER_CANCEL |
1002 | ERROR_CODE_APP_SERVICE_ERROR |
1003 | ERROR_CODE_TIMEOUT |
2001 | ERRORLCODE_AUTH_PENDING_AGREEMENT |