Generate a JSON Web Token (JWT)
Sitecore Experience Edge uses the OAuth authorization framework for security. OAuth allows one program to authorize another program to make changes on behalf of an account holder or end-user.
To execute an operation in the Experience Edge APIs, the calling system must first obtain an authentication token (in JWT format) and include it in every request. Following successful authentication, the calling application has access to an access token used to call the protected APIs.
Request
To request an access token, you use a POST request. Using curl
, the access-token request has the following form:
curl --request POST --url "<auth_url>/oauth/token" --header "content-type: application/x-www-form-urlencoded" --data grant_type=client_credentials --data client_id=<client_id> --data client_secret=<client_secret> --data audience=https://<audience_domain>/<tenant_id>curl --request POST --url " auth_url /oauth/token" --header "content-type: application/x-www-form-urlencoded" --data grant_type=client_credentials --data client_id= client_id --data client_secret= client_secret --data audience=https:// audience_domain / tenant_id
The authority URL, auth_url
, can have one of two values:
-
For sandbox and preproduction instances:
https://auth-beta.sitecorecloud.io/oauth/token
-
For all other instances:
https://auth.sitecorecloud.io/oauth/token
The audience domain, audience_domain
, can have one of two values:
-
For sandbox and preproduction:
https://api-beta.sitecorecloud.io
-
For production:
delivery.sitecore.cloud
Additional parameters are described in the following table.
Parameter |
Description |
---|---|
|
Set this to |
|
The client ID for your tenant. |
|
The client secret for your tenant. |
|
The audience for your tenant, in the form |
Access the client ID and client secret
To access the client ID and client secret:
-
On the menu bar, click Manage
.
-
On the Manage page, click OAuth clients.
-
On the OAuth clients page, click the Delivery client name to open the View details dialog box where the client ID and client secret are displayed.
Access tenant ID
To access the tenant ID, go to /api/status/license
on your Content Hub instance. The tenant ID will be in details.tenant
.
Your tenant ID is typically the name of your Content Hub instance.
Response
In response to the request, you receive the access_token, token_type, and expires_in values. You can pass the retrieved access token as a Bearer token in the authorization header of your HTTP requests.
The period after which JWTs expire is defined by the expires_in property. This is typically set to 24 hours. When one of these tokens expires, it is no longer valid and a new one must be requested.