Before implementing the flow, you must first create custom scopes for the custom authorization server used to authenticate your app from the Admin Console.
If you aren’t using existing libraries, you can make a direct request to the Okta OIDC & OAuth 2.0 API (opens new window) through the /token
endpoint. See Request for token in the next section.
Request for token
The Client Credentials flow is intended for server-side (confidential) client apps with no end user, which normally describes machine-to-machine communication. Your client app needs to have its client ID and secret stored in a secure manner. You can find the client ID and secret on the General tab for your app integration.
Base64-encode the client ID and secret (as shown later) and then pass through Basic Authentication (opens new window) in the request to your custom authorization server's /token
endpoint:
Note: The client ID and secret aren't included in the POST body. Instead, they are in the HTTP Authorization header following the rules of HTTP Basic Auth (opens new window).
Note the parameters that are being passed:
grant_type=client_credentials
: Indicates that you're using the Client Credentials grant type scope
: Must be at least one custom scope that you create. See the Create Scopes section of the Create an authorization server guide.
If the credentials are valid, the app receives an access token:
Base64-encode the client ID and client secret
Use this section to Base64-encode the client ID and secret. When you finish encoding, you can then use the encoded client ID and secret in the HTTP Authorization header in the following format: 'authorization: Basic <Base64-encoded client ID and secret>'
If you're using macOS or Linux:
Open the Admin Console for your org.
Choose Applications > Applications to view the available app integrations.
Select the app that you want to use, and then on the General tab, copy the Client ID and Client secret.
Launch your preferred text editor and then paste the client ID and secret into a new file.
Place the client ID and secret on the same line and insert a colon between them: clientid:clientsecret
Copy the clientid:clientsecret
line to the clipboard.
Launch a terminal and enter the following command, replacing clientid:clientsecret
with the value that you copied.
echo -n clientid:clientsecret | base64
Copy the value that is returned.
Note: Make sure that the entire results are on a single line with no text wrapping.
If you're using Windows:
Open the Admin Console for your org.
Choose Applications > Applications to view the available app integrations.
Select the app that you want to use, and then on the General tab, copy the Client ID and Client secret.
Launch your preferred text editor and then paste the client ID and secret into a new file.
Save the file to C:\temp
and name the file appCreds.txt
.
In Windows Explorer, right-click C:\temp
, and then select CMD Prompt Here from the context menu.
Enter the following command to encode the client ID and client secret:
copycertutil -encode appCreds.txt appbase64Creds.txt
Locate and open appbase64Creds.txt
in C:\temp
, copy its contents, and then close the file.
Note: Delete the appCreds.txt
and the appbase64Creds.txt
files after you finish.
Validate access token
When your app passes a request with an access token, the resource server needs to validate it. See Validate access tokens.