W3cubDocs

/Web APIs

Permissions API

The Permissions API provides a consistent programmatic way to query the status of API permissions attributed to the current context. For example, the Permissions API can be used to determine if permission to access a particular API has been granted or denied, or requires specific user permission.

Note that the permissions from this API effectively aggregate all security restrictions for the context, including any requirement for an API to be used in a secure context, Permissions-Policy restrictions applied to the document, and user prompts. So, for example, if an API is restricted by permissions policy, the returned permission would be denied and the user would not be prompted for access.

Note: This feature is available in Web Workers on platforms that support the WorkerNavigator.permissions property.

Concepts and usage

Historically different APIs handle their own permissions inconsistently — for example the Notifications API provided its own methods for requesting permissions and checking permission status, whereas the Geolocation API did not. The Permissions API provides the tools to allow developers to implement a consistent and better user experience for working with permissions.

The permissions property has been made available on the Navigator object, both in the standard browsing context and the worker context (WorkerNavigator — so permission checks are available inside workers), and returns a Permissions object that provides access to the Permissions API functionality.

Once you have this object you can then perform permission-related tasks, for example querying a permission using the Permissions.query() method to return a promise that resolves with the PermissionStatus for a specific API.

Permission-aware APIs

Not all APIs' permission statuses can be queried using the Permissions API. A non-exhaustive list of permission-aware APIs includes:

Examples

We have made a simple example available called Location Finder. You can run the example live, or view the source code on GitHub.

Read more about how it works in our article Using the Permissions API.

Interfaces

Navigator.permissions and WorkerNavigator.permissions Read only

Provides access to the Permissions object from the main context and worker context respectively.

Permissions

Provides the core Permission API functionality, such as methods for querying and revoking permissions.

PermissionStatus

Provides access to the current status of a permission, and an event handler to respond to changes in permission status.

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
Permissions_API 43 79 No No 30 16.4 No 43 No 30 16.4 4.0
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
Permissions_API 43 79 46 No 30 16 No 43 46 30 16 4.0
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
Permissions_API 43 79 46 No 30 16 No 43 46 30 16 4.0
permission_accelerometer 62 79 No No 49 No No 62 No 46 No 8.0
permission_accessibility-events 62 79 No No 49 No No 62 No 46 No 8.0
permission_ambient-light-sensor 62 79 No No 49 No No 62 No 46 No 8.0
permission_background-sync 62 79 No No 49 No No 62 No 46 No 8.0
permission_camera 64 79 No No 51 16 No 64 No 47 16 9.0
permission_clipboard-read 64 79 No No 51 No No 64 No 47 No 9.0
permission_clipboard-write 64 79 No No 51 No No 64 No 47 No 9.0
permission_geolocation 43 79 46 No 30 16 No 43 46 30 16 4.0
permission_gyroscope 51 79 No No 38 No No 51 No 41 No 5.0
permission_local-fonts 103 103 No No No No No No No No No No
permission_magnetometer 62 79 No No 49 No No 62 No 46 No 8.0
permission_microphone 64 79 No No 51 16 No 64 No 47 16 9.0
permission_midi 43 79 110 No 30 No No 43 110 30 No 4.0
permission_notifications 43 79 46 No 30 No No 43 46 30 No 4.0
permission_payment-handler 66 79 No No 53 No No 66 No 47 No 9.0
permission_persistent-storage 71 79 53 No 58 No No 71 53 50 No 10.0
permission_push 43 79 46 No 30 No No 43 46 30 No 4.0
permission_speaker-selection No No 92 No No No No No 92 No No No
permission_storage-access
113Only available to Google Chrome's first-party sets.
86
113Only available to Edge's first-party sets.
86
No No
99Only available to Opera's first-party sets.
72
No No
113Only available to Google Chrome's first-party sets.
86
No No No No
permission_window-management 100 100 No No 86 No No No No No No No
query 43 79 46 No 30 16 No 43 46 30 16 4.0
request 46 79 No No 33 No No 46 No No No No
requestAll 48 79 No No 35 No No 48 No No No No
revoke 46 79 5147–51 No 33 No No 46 47–51 No No No

api.Permissions

BCD tables only load in the browser

api.Navigator.permissions

BCD tables only load in the browser

api.WorkerNavigator.permissions

BCD tables only load in the browser

See also

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Permissions_API