my.getAuthCode
Get authentication code.
Sample Code
copy
my.getAuthCode({
scopes: 'auth_user',
success: (res) => {
my.alert({
content: res.authCode,
});
},
});
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
scopes | String/Array | N | The scope of auth, there are two types: auth_base , auth_user , by default, its value is auth_base |
Scopes Description
Scopes | Description |
USER_ID | Authorized to obtain the unique user ID. |
NOTIFICATION_INBOX | Authorized to send notification to user's notification in app inbox. |
auth_base | Authorized to obtain the unique user ID. |
auth_user | Authorized to obtain user information. |
USER_ID
and auth_base
are used to silently obtain user ID, silent authorization does not pop the frame and directly obtains user information. All the other scopes are used for proactive user authorization.
Success Callback Function
The incoming parameter is of the Object type with the following attributes:
Field | Type | Mandatory | Description |
authCode | String | Y | Auth code |
authErrorScopes | Key-value | Y | The scope that failed to grant auth, key is the scope and value is the error |
authSuccessScopes | Array | Y | The scope that succeed to grant auth |