<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M74D8PB" height="0" width="0" style="display:none;visibility:hidden">
Loading
Skip to NavigationSkip to Main Content

Validate Tokens with Public Key / Private Key Signed JWTs Using /introspect and a Service Application Integration

API Access Management
Okta Classic Engine
Okta Identity Engine

Overview

Administrators can validate tokens using the /introspect endpoint with a service application integration that uses public and private key client authentication. Generating a JSON Web Token (JWT) with the appropriate audience claim and submitting it to the token and introspect endpoints allows administrators to verify the token validity.

Applies To

  • Okta Identity Engine (OIE)
  • Okta Classic Engine
  • Service Application Integration
  • Public key and private key client authentication
  • JSON Web Token (JWT)

Solution

How is the initial JSON Web Token generated for the token endpoint?

Retrieve the public and private keys from the service application to create the JSON Web Token (JWT) used in the client assertion, and adjust the audience claim to reflect the token endpoint.

  1. Retrieve the public and private keys from the service application.
  2. Create the JWT using a tool such as jwt.io. Fill the Header, Payload, and Verify Signature sections with the relevant data.
  3. Adjust the aud claim to reflect the token endpoint: https://<subdomain>.okta.com/oauth2/v1/token.

The following image demonstrates the configuration of the JSON Web Token with the adjusted audience claim for the token endpoint.

token

Submit the generated token to the token endpoint to retrieve an access token.

Copy the generated token and use it as the client assertion parameter value in a request to the token endpoint to retrieve the access token.

curl --location 'https://<subdomain>.okta.com/oauth2/v1/token?client_assertion=<insertGeneratedTokenHere>' \
--header 'Accept: application/json' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'scope=okta.users.read' \
--data-urlencode 'client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer'

Okta returns an access token along with the token type, expiration, and scope values in the following format.

{
    "token_type": "Bearer",
    "expires_in": 3600,
    "access_token": "eyJraWQiOiIzTjFVNlB2dnpmS21xWDVRLUFFNmlyTU96MEFXeGhU...",
    "scope": "okta.users.read"
}

How is the access token validated using the introspect endpoint?

Generate a new JSON Web Token with the audience claim adjusted for the introspect endpoint, and submit it along with the access token to verify its validity.

  1. Generate a new JWT.
  2. Adjust the aud claim to reflect the introspect endpoint: https://<yourDomain>.okta.com/oauth2/v1/introspect.

The following image demonstrates the configuration of the new JSON Web Token with the adjusted audience claim for the introspect endpoint.

introspect

Submit the new JWT and the access token to the introspect endpoint using the following command.

curl --location 'https://<subdomain>.okta.com/oauth2/v1/introspect?client_assertion=<newJWTToken>' \
--header 'Accept: application/json' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'token=<AccessToken>' \
--data-urlencode 'token_type_hint=access_token' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer'

If the access token is valid, Okta returns a response containing an active status of true along with other data about the access token.

{
    "active": true,
    "scope": "okta.users.read",
    "exp": 1731416981,
    "iat": 1731413381,
    "sub": "0oa5aqr7pwKCxZAhH0x7",
    "aud": "https://<subdomain>.okta.com",
    "iss": "https://<subdomain>.okta.com",
    "jti": "AT.8GaLb97SoJGyNjLMKWcsHyMDbLMoTHoVe9chK1Flm5k",
    "token_type": "Bearer",
    "client_id": "0oa5aqr7pwKCxZAhH0x7"
}

Related References

Loading
Validate Tokens with Public Key / Private Key Signed JWTs Using /introspect and a Service Application Integration | Okta Support