Obtaining and sending OAuth access tokens for Data API calls
Key Takeaway
For a server-to-server Data API call, send a POST to /dwsso/oauth2/access_token with grant_type=client_credentials. Put your client ID and client password in an HTTP Basic Authorization header. Then send the returned token as Authorization: Bearer <access_token> on each Data API request.
When an external system such as a CRM calls the OCAPI Data API, each request must carry an OAuth 2.0 access token that proves who is calling. You register the client application in Account Manager to get a client ID and a client password. The application exchanges those credentials for a short-lived token, then sends that token as a Bearer token in every Data API request.
Two OAuth 2.0 contexts
OCAPI uses OAuth 2.0 in two contexts. Both are for cases where the shopping customer context of a JWT does not fit. The right context depends on whether a person is involved.
| Server-to-server | Business Manager user | |
|---|---|---|
| Who is involved | One system talks directly to the Data API, with no end user | A Business Manager user interacts with the system |
| Requests are authenticated in the context of | A client ID | That user |
| Grant | Client credentials grant | Business Manager user grant or Authorization Code Grant |
| APIs | Data API | Shop API or Data API |
An external system such as a CRM that calls the Data API on its own, with no end user, is the server-to-server case. That case uses the client credentials grant.