The Scopes API provides the ability to dynamically manage your access scopes within an embedded context. > Tip: > To learn more about declaring and requesting access scopes, as well as required vs. optional scopes, refer to [manage access scopes](/docs/apps/build/authentication-authorization/app-installation/manage-access-scopes).
Provides utilities to query, request, and revoke access scopes for the app using the Admin API.
The Scopes API enables embedded apps and extensions to request merchant consent for access scopes.
Queries Shopify for the scopes for this app on this shop
Requests the merchant to grant the provided scopes for this app on this shop This will open a [permission grant modal](/docs/apps/build/authentication-authorization/app-installation/manage-access-scopes#request-access-scopes-using-the-app-bridge-api-for-embedded-apps) for the merchant to accept or decline the scopes.
Revokes the provided scopes from this app on this shop
The scopes that have been granted on the shop for this app
The optional scopes that the app has declared in its configuration
The required scopes that the app has declared in its configuration
`UserResult` represents the results of a user responding to a scopes request, i.e. a merchant user’s action taken when presented with a grant modal.
'granted-all' | 'declined-all'
The Scopes API provides the ability to dynamically manage your access scopes within an embedded context. > Tip: > To learn more about declaring and requesting access scopes, as well as required vs. optional scopes, refer to [manage access scopes](/docs/apps/build/authentication-authorization/app-installation/manage-access-scopes).
const { granted } = await shopify.scopes.query();
const response = await shopify.scopes.request(['read_products', 'write_discounts']);
if (response.result === 'granted-all') {
// merchant has been granted access — continue
...
}
else if (response.result === 'declined-all') {
// merchant has declined access — handle accordingly
...
}
await shopify.scopes.revoke(['read_products']);