1e41f4b71Sopenharmony_ci# Declaring Permissions 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ciTo request permissions for your application, declare all the permissions one by one in the project configuration file. 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci## Declaring Permissions in the Configuration File 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ciDeclare the permissions required by your application under **requestPermissions** in the **module.json5** file. 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci| Field| Description| Data Type| Value Range| 10e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 11e41f4b71Sopenharmony_ci| name | Name of the permission to request.| String| This field is mandatory. The value must be a permission defined in the system. For details, see [Permissions for All Applications](permissions-for-all.md).| 12e41f4b71Sopenharmony_ci| reason | Reason for requesting the permission.| String| This field is optional. It is used for application release verification. It must be specified for a user_grant permission and support multilingual adaptation.<br>It can be referenced as a string resrouce in $string: \*\*\* format.<br>For details, see [Specifications for reason](#specifications-for-reason). | 13e41f4b71Sopenharmony_ci| usedScene | Context in which the permission is used. It has two parameters:<br>- **abilities**: names of the abilities (UIAbility or ExtensionAbility) that use the permission.<br>- **when**: when the permission is used.| Object| **usedScene** is mandatory, where:<br>- **abilities** is optional. The value is a string array of multiple UIAbility or ExtensionAbility names.<br>- **when** is optional. Set it to **inuse** or **always** for a user_grant permission. It cannot be empty when set. | 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci## Example 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci> **NOTE** 18e41f4b71Sopenharmony_ci> 19e41f4b71Sopenharmony_ci> The values **ohos.permission.PERMISSION1** and **ohos.permission.PERMISSION2** are only examples and do not exist. Set permissions to match your case. 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ci```json 22e41f4b71Sopenharmony_ci{ 23e41f4b71Sopenharmony_ci "module" : { 24e41f4b71Sopenharmony_ci // ... 25e41f4b71Sopenharmony_ci "requestPermissions":[ 26e41f4b71Sopenharmony_ci { 27e41f4b71Sopenharmony_ci "name" : "ohos.permission.PERMISSION1", 28e41f4b71Sopenharmony_ci "reason": "$string:reason", 29e41f4b71Sopenharmony_ci "usedScene": { 30e41f4b71Sopenharmony_ci "abilities": [ 31e41f4b71Sopenharmony_ci "FormAbility" 32e41f4b71Sopenharmony_ci ], 33e41f4b71Sopenharmony_ci "when":"inuse" 34e41f4b71Sopenharmony_ci } 35e41f4b71Sopenharmony_ci }, 36e41f4b71Sopenharmony_ci { 37e41f4b71Sopenharmony_ci "name" : "ohos.permission.PERMISSION2", 38e41f4b71Sopenharmony_ci "reason": "$string:reason", 39e41f4b71Sopenharmony_ci "usedScene": { 40e41f4b71Sopenharmony_ci "abilities": [ 41e41f4b71Sopenharmony_ci "FormAbility" 42e41f4b71Sopenharmony_ci ], 43e41f4b71Sopenharmony_ci "when":"always" 44e41f4b71Sopenharmony_ci } 45e41f4b71Sopenharmony_ci } 46e41f4b71Sopenharmony_ci ] 47e41f4b71Sopenharmony_ci } 48e41f4b71Sopenharmony_ci} 49e41f4b71Sopenharmony_ci``` 50e41f4b71Sopenharmony_ci 51e41f4b71Sopenharmony_ci## Specifications for reason 52e41f4b71Sopenharmony_ci 53e41f4b71Sopenharmony_ciThe **reason** field (reason for requesting the permission) is mandatory when a user_grant permission is requested. You must declare each required permission in the application's configuration file. 54e41f4b71Sopenharmony_ci 55e41f4b71Sopenharmony_ciIn the dialog box displayed for the user to grant the permission, the [permission group](app-permission-mgmt-overview.md#permission-groups-and-permissions) is displayed. For details about permission groups, see [Application Permission Groups](app-permission-group-list.md). 56e41f4b71Sopenharmony_ci 57e41f4b71Sopenharmony_ci### Specifications and Suggestions for the reason Field 58e41f4b71Sopenharmony_ci<!--RP1--> 59e41f4b71Sopenharmony_ci1. Keep the sentence concise without redundant separators. 60e41f4b71Sopenharmony_ci 61e41f4b71Sopenharmony_ci **Recommended sentence pattern**: Used for something/Used to do something/Used for doing something. 62e41f4b71Sopenharmony_ci 63e41f4b71Sopenharmony_ci **Example**: Used for code scanning and photographing. 64e41f4b71Sopenharmony_ci 65e41f4b71Sopenharmony_ci2. To facilitate multilingual adaptation, keep **reason** under 72 characters (36 Chinese characters displayed in two lines on the UI). It cannot exceed 256 characters. 66e41f4b71Sopenharmony_ci 67e41f4b71Sopenharmony_ci3. If **reason** is not set, the default reason will be used. 68e41f4b71Sopenharmony_ci<!--RP1End--> 69e41f4b71Sopenharmony_ci### Presentation of reason 70e41f4b71Sopenharmony_ci 71e41f4b71Sopenharmony_ciThe reason for requesting a permission can be presented in two modes: authorization pop-up window and permission details page of an application in **Settings** > **Privacy** > **Permission manager**. 72e41f4b71Sopenharmony_ci 73e41f4b71Sopenharmony_ci1. For the permissions in the **Phone**, **Messaging**, **Calendar**, **Contacts**, and **Call logs** permission groups, the content and usage of each permission requested must be presented to the user. 74e41f4b71Sopenharmony_ci 75e41f4b71Sopenharmony_ci **Sentence pattern**: Permissions A, used to/for ... Permission B, used to/for ... 76e41f4b71Sopenharmony_ci 77e41f4b71Sopenharmony_ci **Example**: Permission A, used to obtain the call status and mobile network information. Permission B, used for secure operation and statistics charging services. 78e41f4b71Sopenharmony_ci 79e41f4b71Sopenharmony_ci2. For the permissions in other permission groups, the reason for using the first permission requested is presented to the user. The permissions are sorted as they appear in permission groups under **Permission manager**. 80e41f4b71Sopenharmony_ci 81e41f4b71Sopenharmony_ci **Example**: If a permission group consists of permissions A, B, and C in sequence, and permissions C and B are requested, the reason for using permission B is presented to the user. 82