Pages

22 August, 2023

Generate XM Cloud (Experience) Edge API Key

Ways to generate the Edge API Key

Edge API Key can be generated in three ways.
  1. Using Token API
  2. Using XM Cloud Deploy REST API
  3. Using XM Cloud Portal
In general, there are three steps to follow to create the Edge API Key.
  • Create client details from Cloud Portal. This will get you client id and client secret. 
  • Request JWT using client id and client secret. JWT is the access token to be used for the next step. 
  • Using the JWT, request for API Key. 
Option 1: Using Token API

Step 1: Create Edge Administration Client for an XM Cloud Environment 
  • Go to XM Cloud Deploy App (https://deploy.sitecorecloud.io/) → Credentials Environment Create Credentials → Edge Administration → Create
  • Copy client id and client secret. Client secret should be copied now and it cannot be retrieved again. 
Generate Edge Administration Credential

Select Environment

Copy Client ID and Client Secret

Step 2: Request JWT for Experience Edge using Client ID and Secret

Sending a POST request with the client id and client secret will provide the access_token which can be used to create the API Key.


Step 3: Create API Key using generated access_token. 

Sending a POST request to https://edge.sitecorecloud.io/api/apikey/v1 with scopes "audience-delivery" (authorizes access to the Delivery API) and "content-#everything#" and access_token as bearer token (allows access to all content) will generate the API key. With this Edge API key in the HTTP headers, you will be able to query data and see the results returned. In the below sample request, sc_apikey will be K3p2VCt1VHNsT1pwNFFXBhbWVtZWF0cmEzMmYwLXhtY2xvdWRuZWhlbS1kZXYtMmRmZQ==.

Option 2: Using XM Cloud Deploy REST API

Step 1: Create Organization or Environment Automation Client  

Similar to Step 1 of Option 1, you can create Organization or Environment automation client from the cloud portal. 
  • For Organization Credential: Go to XM Cloud Deploy App (https://deploy.sitecorecloud.io/) → Credentials → Create Credentials → Create
  • For Environment Credential: Go to XM Cloud Deploy App (https://deploy.sitecorecloud.io/) → Credentials → Environment → Create Credentials → Automation → Create
  • Copy client id and client secret. Client secret should be copied now and it cannot be retrieved again. 

Step 2: Request JWT for Experience Edge using Client ID and Secret

Sending a POST request with the client id and client secret will provide the access_token which can be used to create the API Key. 


Step 3: Create API Key using Deploy API. 

Sending a POST request to https://xmclouddeploy-api.sitecorecloud.io/api/environments/v1/<your_environment_id>/obtain-edge-token with access_token as bearer token will generate the API key. Replace the HTTP request URL with the appropriate environment ID. Response will have the apiKey. 


Option 3: Using XM Cloud Portal

XM Cloud Edge API key for an environment can be retrieved from two different places in Cloud Portal

XM Cloud Portal App Dashboard
  • In the XM Cloud App Dashboard, click Sites, in the action menu , click Settings, click Developer Settings and get the Key from SITECORE_API_KEY environment variable. 

XM Cloud Deploy App
  • In the XM Cloud Deploy App, click Projects, click the project that you created, click the Environment, click Details tab and get the Key from Edge token value variable. 

No comments:

Post a Comment

blockquote { margin: 0; } blockquote p { padding: 15px; background: #eee; border-radius: 5px; } blockquote p::before { content: '\201C'; } blockquote p::after { content: '\201D'; }