1# PermissionRequestResult 2 3<!--Kit: Ability Kit--> 4<!--Subsystem: Security--> 5<!--Owner: @xia-bubai--> 6<!--SE: @linshuqing; @hehehe-li--> 7<!--TSE: @leiyuqian--> 8 9The **PermissionRequestResult** module defines the permission request result returned by [requestPermissionsFromUser](js-apis-abilityAccessCtrl.md#requestpermissionsfromuser9). 10 11> **NOTE** 12> 13> - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. 14> - The APIs of this module can be used only in the stage model. 15 16## Properties 17 18**System capability**: SystemCapability.Security.AccessToken 19 20| Name| Type| Read Only| Optional| Description| 21| -------- | -------- | -------- | -------- | -------- | 22| permissions | Array<string> | Yes| No| Permissions requested.<br> **Atomic service API**: This API can be used in atomic services since API version 11.| 23| authResults | Array<number> | Yes| No| Result of the permission request.<br>- **-1**: The permission is not granted. If **dialogShownResults** is **true**, it is the first time that the user requests the permission. If **dialogShownResults** is **false**, the permission has been set and no dialog box is displayed. The user can modify the permission settings in **Settings**.<br>- **0**: The permission is granted.<br>- **2**: The permission request is invalid. The possible causes are as follows: 1. The permission is not declared in the configuration file. 2. The permission name is invalid. 3. The conditions for requesting the permission are not met. For details, see [ohos.permission.LOCATION](../../security/AccessToken/permissions-for-all-user.md#ohospermissionlocation) and [ohos.permission.APPROXIMATELY_LOCATION](../../security/AccessToken/permissions-for-all-user.md#ohospermissionapproximately_location).<br> **Atomic service API**: This API can be used in atomic services since API version 11.| 24| dialogShownResults<sup>12+</sup> | Array<boolean> | Yes| Yes| Whether to display a dialog box.<br>The value **true** means to display a dialog box;<br>the value **false** means the opposite.<br> **Atomic service API**: This API can be used in atomic services since API version 12.| 25| errorReasons<sup>18+</sup> | Array<number> | Yes| Yes| Return value.<br>**0**: The request is valid.<br>**1**: The permission name is invalid.<br>**2**: The permission is not declared in the configuration file.<br>**3**: The conditions for requesting the permission are not met. For details, see the permission description in [Permission List](../../security/AccessToken/permissions-for-all-user.md). Currently, only the location permissions are involved.<br>**4**: The user does not agree to the privacy statement.<br>**5**: This permission cannot be requested via a dialog box.<br>**6**: This permission is forcibly controlled by the system policy and cannot be requested via a dialog box.<br>**12**: The service is abnormal.<br> **Atomic service API**: This API can be used in atomic services since API version 18.| 26 27## Usage 28 29The permission request result is obtained through an **atManager** instance. 30 31**Example** 32For details about how to obtain the context in the example, see [Obtaining the Context of UIAbility](../../application-models/uiability-usage.md#obtaining-the-context-of-uiability). 33<!--code_no_check--> 34```ts 35import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; 36import { BusinessError } from '@ohos.base'; 37import common from '@ohos.app.ability.common'; 38 39let atManager = abilityAccessCtrl.createAtManager(); 40try { 41 let context: Context = this.getUIContext().getHostContext() as common.UIAbilityContext; 42 atManager.requestPermissionsFromUser(context, ["ohos.permission.CAMERA"]).then((data) => { 43 console.info("data:" + JSON.stringify(data)); 44 console.info("data permissions:" + data.permissions); 45 console.info("data authResults:" + data.authResults); 46 console.info("data dialogShownResults:" + data.dialogShownResults); 47 console.info("data errorReasons:" + data.errorReasons); 48 }).catch((err: BusinessError) => { 49 console.error("data:" + JSON.stringify(err)); 50 }) 51} catch(err) { 52 console.error(`catch err->${JSON.stringify(err)}`); 53} 54``` 55