Cert++
Close

Choosing the OCAPI authentication model by caller context

Key Takeaway

Choose the OCAPI authentication model by who is calling. A back-end system that calls the Data API with no user involved uses the OAuth client credentials grant, so the token request sets grant_type to client_credentials, even when the client authenticates with a signed JWT and key pair.

Every Open Commerce API (OCAPI) request comes from a caller. The caller can be an anonymous shopper, a logged-in or guest customer, a Business Manager user acting as an agent, or a back-end system with no user at all. OCAPI matches each caller type to an authentication model: none, a customer JWT, an OAuth Business Manager user grant, or an OAuth client credentials grant. The right choice depends on which API you call (Shop or Data) and on whose behalf the request runs. Underneath any authentication model, the request also needs an enabled client ID and matching client permissions.

Client ID and client permissions

Every OCAPI request must identify a client ID that is registered and enabled in Account Manager. A request with no client ID gets HTTP 400 (Bad Request). Authentication is a separate layer on top of the client ID.

Whatever the authentication model, you must also configure client permissions in "Open Commerce API Settings" in Business Manager. A valid token alone does not grant access to any resource. By default no client permission is granted, so a request without matching permissions returns HTTP 401 (Unauthorized), unlike the HTTP 400 for a missing client ID. Most Data API resources are organization-specific, so they support only global client permissions.

Changes do not take effect instantly. Open Commerce API Settings are cached for up to three minutes. Enabling or disabling a client ID also does not change its status right away, because client IDs are cached before they are revalidated.

B2C Commerce Developer Study Guide

Checklist progress

0/237Learned

Given a business requirement, use OCAPI Shop and Data APIs to enable interoperability with an external system

0/10

Prepare for the Exam

Play Today's Certle

Study Community

Ask questions and get the latest info from other B2C Commerce Developer studiers. 796 members and growing.