OAuth Scopes and user permissions

OAuth Scopes

Custom Applications can use any of the available Composable Commerce APIs. This allows you to extend the functionality and build custom features for any of the Composable Commerce APIs and the Merchant Center.

Therefore, Custom Applications must specify the list of OAuth Scopes needed by the application.

For example, if you are developing a Custom Application to manage Channels you would probably need the OAuth Scopes view_products and manage_products. On top of that, you might decide to also view Customers information.

To fulfill these requirements, your Custom Application would require the following OAuth Scopes:

  • view_products, view_customers
  • manage_products

These OAuth Scopes must be specified in your Custom Application config, using the oAuthScopes field.

custom-application-config.jsonjson
{
"oAuthScopes": {
"view": ["view_products", "view_customers"],
"manage": ["manage_products"]
}
}

Notice here how the OAuth Scopes are grouped by the two fields view and manage.

This grouping determines the mapping and relation between OAuth Scopes and user permissions.

Additional OAuth Scopes

Defining oAuthScopes in the Custom Application config allows using permissions limited to 1 unique pair (view/manage) specific to the Custom Application.

For more granular permissions, for example, to allow the team access to only certain parts or functionality of the Custom Application, additional OAuth Scopes can be requested as part of various permission groups.

These additional OAuth Scopes must be specified in your Custom Application config, using the additionalOAuthScopes field.

In the following example, permission group named team_a allows to manage orders but not see discount codes, while permission group named team_b allows both.

custom-application-config.jsonjson
{
"oAuthScopes": {
"view": ["view_products", "view_customers"],
"manage": ["manage_products"]
},
"additionalOAuthScopes": [
{
"name": "team-a",
"view": [],
"manage": ["manage_orders"]
},
{
"name": "team-b",
"view": ["view_discount_codes"],
"manage": ["manage_orders"]
}
]
}

User permissions

In the Merchant Center, you can assign user permissions to Teams to grant or restrict access to certain parts and functionalities of the Merchant Center. See user permissions in Merchant Center for more information.
The same concepts apply for Custom Applications as well. Once your Custom Application has been installed in your Organization, you can assign user permissions for your Custom Application to each specific Team.

Each Custom Application gets a unique pair of user permissions: "view" and "manage."

  • When assigning "view"-only permission to a Team, only the view_ OAuth Scopes are used to authorize API requests.
  • When assigning "manage" permission to a Team, both view_ and manage_ OAuth Scopes are used to authorize API requests.

The permission names are unique to each Custom Application and, by default, they derive from the entryPointUriPath, based on the following format: {View,Manage}<EntryPointUriPath>.

Here are some examples:

entryPointUriPathUser permission
avengers{View,Manage}Avengers
the-avengers{View,Manage}TheAvengers
the_avengers{View,Manage}The_Avengers
avengers-01{View,Manage}Avengers/01
avengers_01{View,Manage}Avengers_01

Optional additional permissions derive from the entryPointUriPath and the provided permission group name, based on the following format: {View,Manage}<EntryPointUriPath><PermissionGroupName>

Here are some examples:

entryPointUriPathPermission group nameUser permission
avengersthor{View,Manage}AvengersThor
the-avengersiron-man{View,Manage}TheAvengersIronMan

Ultimately, user permissions should be applied and enforced in the actual Custom Application code. For example to restrict access to certain pages, or to deactivate a button, etc.

To learn more about it, head over to the Permissions in the development section.