Headless API Authentication
Quick start guide - Authenticating a client
Obtaining Credentials
Navigate to the Ucommerce Backoffice (
/ucommerce) as an administrator.In the Settings menu, click
API Access.When having multiple stores, one must be selected in the top-right corner dropdown.
Take note of the
Client IDand the matchingSecret.Add the URL of your client to the
URL Whitelist.
The headless API uses OAuth2 for authentication. This involves 2 steps: getting an authentication code and exchanging the code for a token.
Connect
curl -D- -G \
<base_url>/api/v1/oauth/connect \
-d client_id=<CLIENT_ID> \
-d redirect_uri=<REDIRECT_URI> \
-d response_type=coderedirect_uriis where you will be redirected to after the call has finished. This needs to match a redirect URL specified in theURL Whitelist.
The expected response is a 302 (Found or Moved Temporarily).
The location header contains the authentication code. This will be used in the next step.
The code expires after 1 minute. A new code must be requested if it has not been exchanged for a token.
Exchange code for a token
The authorization header above must be formatted. You can find an explanation and examples here: Token endpoint - Authorization Header
An example of an expected response:
access_tokenwill be used in all future requests.expires_incan be used to identify when to refresh the token.refresh_tokenwill be used to refresh an expired or expiring token.
Using the token
All subsequent requests to the Headless API require the access_token in their respective Authorization headers.
Last updated
Was this helpful?