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 IEFT 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
Login to the target Spark tenant. Access the Keycloak console from the User menu.
Login to the Keycloak Admin Console using your admin credentials.
On the left pane click Clients.
In the Clients list tab, click on Create client.
Fill in the required details and click Next.
KeyValueClient ID
Your Client ID name
Client type
openid-connectApply the following settings and click Next. Service account roles should be checked automatically and greyed out.
KeyValueStandard flow enabled
OffDirect access grants
OffClient authentication
OnAuthorization
OnLeave Login Settings unfilled and click Save.
Create client mappers
Click on the Client scopes tab.
In the Assigned client scope column, click on
{clientname}-dedicated, e.g.ccdemo-dedicated.Click Add mapper and select By configuration from the dropdown list.
Click on Audience and enter the following:
KeyValueName
audIncluded Client Audience
product-factoryAdd to access token
OnClick Save.
Click Add mapper and select By configuration from the dropdown list.
Click on Hardcoded claim and enter the following:
KeyValueName
realmToken Claim Name
realmClaim value
{your-tenant-name}Claim JSON Type
StringAdd to access token
OnClick Save.
Click Add mapper and select By configuration from the dropdown list.
Click on Group Membership and enter the following:
KeyValueName
groupsToken Claim Name
groupsAdd to access token
OnFull Group Path
OffClick Save.
Add client credentials to groups
Go to the Service Account Roles tab.
Just below the tab, click the link labeled: “To manage detail and group mappings, click on the username {your service account name}.”
On the User Details page, navigate to the Groups tab.
Click Join Group, select the desired group (for example
supervisor:pf) and click Join.
Create the credential
On the left panel, click Clients under Manage.
Select and click into your newly created Client.
Click on 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.
Open an application that can be used to test APIs and import cURL statements. Import the following cURL statement:
Replace the the
{environment},{tenant},{client_id},{client_secret}with the appropriate values.Send the request.
From the response, retrieve the value of the
access_tokenkey.
Assign Client Credentials to a Spark folder
If you would like to assign the Client Credential to a specific folder to limit the permissible access, you can follow the instructions in Set permissions on folders via API and define the service-account member.
Test the Client Credentials
With a Keycloak token, you can make an API request against your Spark tenant to ensure the token is working properly. In this example we will use the GET Categories API.
Follow the steps in Create the credential to get the access token.
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
