目录

Authorization

has.authorize

has.authorize(Object object)

Initiates an authorization request to a user in advance. After the API is called, a dialog box will be displayed immediately, asking the user to authorize the atomic service to use a feature or acquire user data. However, it will not actually call the corresponding API to use the feature or acquire the data. If the user has already agreed to the authorization, no dialog box is displayed and a success message is returned directly.

Since: 1.0.0

Parameters

The input parameter is an object containing the following fields.

Parameter Type Mandatory Description
scope string Yes Scope of the permission to be obtained. For details, see Scope List.
success function No Callback triggered when the API call is successful.
fail function No Callback triggered when the API call fails.
complete function No Callback triggered when the API call is complete, regardless of success or failure.

To apply for permissions, declare all the permissions one by one in the project configuration file. For details about the configuration method, see Declaring Permissions.

Error code information

Error Code Error Message
101 authorize fail.
102

1. scope is not support.

2. scope is invalid.

103 authorize reject.
11000201

authorize error.

For details, see Universal Error Codes.

Example:

has.authorize({
  scope: 'scope.userLocation',
  success: () => {
    console.info('authorize success');
  },
  fail: (err) => {
    console.error('authorize fail', err);
  },
  complete: (res) => {
    console.info('authorize complete', res);
  }
});