my.getAuthCode

Get authentication code.

Sample Code

copy
my.getAuthCode({
  scopes: 'auth_user',
  success: (res) => {
    my.alert({
      content: res.authCode,
    });
  },
});

Parameters

NameTypeMandatoryDescription
scopesString/ArrayNThe scope of auth, there are two types: auth_base
auth_user, by default, its value is auth_base

Scopes Description

ScopesDescription
USER_IDAuthorized to obtain the unique user ID.

NOTIFICATION_INBOX

Authorized to send notification to user's notification in app inbox.

auth_baseAuthorized to obtain the unique user ID.
auth_userAuthorized 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:

FieldTypeMandatoryDescription
authCodeStringYAuth code
authErrorScopesKey-valueYThe scope that failed to grant auth, key is the scope and value is the error
authSuccessScopesArrayYThe scope that succeed to grant auth