Applications

An overview of Commerce Layer's OAuth 2.0 application types and how to create them

To use Commerce Layer API you need to be authorized in the first place. This means you need to get a valid access token. The permissions you're granted authenticating with that token are determined by the type of API client you used to get it. Three different types of applications are currently available in order to get your credentials: sales channel, integration, and webapp. Which one to use depends on your specific use case.

Sales channel

Sales channel applications are used to build any customer touchpoint (e.g. your storefront with a fully-functional shopping cart and checkout flow).

Sales channels grant non-confidential (public) API credentials. They can authenticate by providing just a client ID and their permissions are restricted so that they can be safely used client-side and their tokens exposed to the public without any risks. For example, they can access only one order at a time (the one associated with the shopping cart you're about to checkout, identified by a not guessable, unique hashID) and respond with a 401 Unauthorized error if you try to request a list of orders.

Sales channels require a market in scope when requesting their access tokens. This way all the API call results are automatically filtered based on the specified scope. In particular:

  • Only the SKUs that are sellable in that market are returned (to be sellable in a market an SKU must have a price in the market's price list and at least one stock item in one of the market's stock locations, regardless of its quantity).

  • Only the prices associated with that market's price list are returned.

  • The stock availability is calculated by checking only the stock locations associated with that market (e.g. only the stock items associated with that market's stock locations are returned).

Using a sales channel is the most straightforward way to build your customer touchpoint. Anyway, if you want to have complete control over the grants brought to the access tokens, you can always use an integration. Just make sure not to expose the secret on the client, by building a dedicated backend for frontend (BFF), or properly leveraging serverless functions.

Integration

Integration applications are used to develop backend integrations with any 3rd-party system.

Integrations provide confidential API credentials. They need a client ID and a client secret to authenticate and can have one of two roles:

  • Read-only — to perform GET requests on any single resource or list of resources.

  • Admin — to perform any CRUD (create, retrieve, update, or delete) action on any resource.

Enterprise users can define custom roles for their integration applications, specifying custom permissions on CRUD actions at the single resource level so as to leverage a granular control, tailored to their needs.

Webapp

Webapp applications are used to develop custom web apps or services for your users, extending Commerce Layer backend with any functionality that is not provided out of the box.

Webapps let you execute the OAuth 2.0 authorization code grant flow to get an access token after a user authorizes an app. They don't come with their own roles and permissions, since they get the set of permissions of the authenticated user.

Creating an application

Head over to the Applications section by clicking on the related item in the nav menu sidebar on the left of your dashboard. If you're about to create your first application click on the Start button:

Otherwise, the list of your current available applications will be displayed. You can access each one individually to update or delete them. To create a new one, click on Add new on the top right of the list:

The following page is where you can select the kind of application you want to create.

Sales channel

To create a sales channel application, select the Sales channel card, give your new application a meaningful name, and click on the Get credentials button:

On successful creation, you will enter the application details page, where you can find and copy to clipboard your API credentials (client ID, base endpoint, and allowed scopes):

To update your sales channel just click on Edit at the top right corner. To delete it use the Remove application button at the bottom of the page.

Integration

To create an integration application, select the Integration card, give your new application a meaningful name, choose its role from the related dropdown, and click on the Get credentials button:

On successful creation, you will enter the application details page, where you can find and copy to clipboard your API credentials (client ID, client secret, and base endpoint):

To update your integration just click on Edit at the top right corner. To delete it use the Remove application button at the bottom of the page.

Webapp

To create a webapp application, select the Webapp card, give your new application a meaningful name, insert the redirect URI (necessary for the authorization code flow), and click on the Get credentials button:

On successful creation, you will enter the application details page, where you can find and copy to clipboard your API credentials (client ID, client secret, base endpoint, and allowed scopes):

To update your webapp just click on Edit at the top right corner. To delete it use the Remove application button at the bottom of the page.

Last updated