Client credentials grant (OAuth 2.0)
Client credentials
The client credentials grant feature of OAuth 2.0 enables server-to-server authentication, without involving actual users. It provides a special ID for the server, allowing it to assign permissions as if it were a real user. For more details, see IETF RFC 6749.
The client credentials grant is particularly useful in Spark systems when performing API operations that don't involve any user interaction. This can include CI/CD operations or any other tasks that require communication with OAuth 2.0 protected APIs.
Create client
Sign in to the target Spark tenant. Access the Keycloak console from the User menu.
On the left pane select Clients.
In the Clients list tab, select Create client.
Fill in the required details and select Next.
KeyValueClient ID
Your Client ID name
Client type
openid-connectApply the following settings and select Next. Service account roles should be checked automatically and grayed out.
KeyValueStandard flow enabled
OffDirect access grants
OffClient authentication
OnAuthorization
OnLeave Login Settings unfilled and select Save.
Create client mappers
Select the Client scopes tab.
In the Assigned client scope column, select
{clientname}-dedicated, for exampleccdemo-dedicated.Select Add mapper, then select By configuration from the dropdown list.
Select Audience and enter the following:
KeyValueName
audIncluded Client Audience
product-factoryAdd to access token
OnSelect Save.
Select Add mapper and select By configuration from the dropdown list.
Select Hardcoded claim and enter the following:
KeyValueName
realmToken Claim Name
realmClaim value
<mytenant>Claim JSON Type
StringAdd to access token
OnSelect Save.
Select Add mapper and select By configuration from the dropdown list.
Select Group Membership and enter the following:
KeyValueName
groupsToken Claim Name
groupsAdd to access token
OnFull Group Path
OffSelect Save.
Add client credentials to groups
Go to the Service Account Roles tab.
Just below the tab, select the link labeled: To manage detail and group mappings, click on the username {your service account name}.
On the User Details page, select the Groups tab.
Select Join Group, select the desired group (for example
supervisor:pf) and select Join.
Create the credential
On the left panel, select Clients under Manage.
Select your newly created client.
Select the Credentials tab at the top.
Copy the Client secret using the clipboard icon. Securely store this value.
Copy the Client ID from the top left corner of the page. Securely store this value.
Run this curl statement:
Replace the
{environment},{tenant},{client_id},{client_secret}with the appropriate values.Submit the request.
From the response, retrieve the value of the
access_tokenkey.Assign the client credential the appropriate permissions to folders in Set permissions.
Create a
GETAPI request:URI:
https://excel.{environment}/api/v1/lookup/getcategories.Header:
Authorization:Bearer {token}.
Send the API request.
You should receive a
200 OKresponse.
Last updated
