Ways to generate the Edge API Key
Edge API Key can be generated in three ways.
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
No comments:
Post a Comment