Integrate the OAuth Client Credentials

This topic describes the Java SDK OAuth Client Credentials flow integration.


The Client Credentials grant is used when applications request an access token to access their own resources, not on behalf of a user. In this flow, the client application provides a client ID and a client secret to obtain an access token from a tenant. This grant flow is mainly used for machine to machine communications.

Before you begin

Integrate the SDK

Follow the steps below to use this SDK to get the access_token.

Step 1: Configure an OAuthClient instance using the Java SDK

  • Import the SDK as specified in the Before you get started section.
  • Pass the required parameters to create an OAuthClient instance.
import com.cyberark.client.OAuthClient;

// provide confidential client details for client_id and client_secret

Step 2: Get the tokens

Use the oauthClient instance to call the following builder methods and execute the request to receive tokens.

TokenHolder tokenHolder = oauthClient.requestTokenWithClientCreds()
  access_token: "YOUR_ACCESS_TOKEN",
  expires_in: 18000,
  scope: "all",
  token_type: "Bearer"

Common Methods

For common methods, such as refreshToken, revokeToken and claims, refer to CyberArk Identity Java SDK reference.