gray-machine-46287
07/03/2025, 2:48 PMbrief-egg-61061
07/03/2025, 2:48 PMbrief-egg-61061
07/03/2025, 2:48 PMprivate_key_jwt
). This method uses a JSON Web Token (JWT) signed by the client's cryptographic key, rather than transmitting a client secret. The JWT Bearer profile leverages asymmetric cryptography, which is generally considered more secure than using shared secrets (as in client_secret_basic
or client_secret_post
), because the private key never leaves the client and only the public key is shared with the authorization server. This reduces the risk of credential leakage and supports strong authentication guarantees. To use this method, you configure the client with --token-endpoint-auth-method private_key_jwt
and provide a JWKS URI or key set. The client then authenticates by signing a JWT with its private key and sending it to the token endpoint, where the server verifies it using the public key. > The JWT Bearer Grant Type mechanism is similar to Basic and Body Authentication, but instead of sending the client ID and client secret, the client sends a JSON Web Token (JWT) which was signed by its cryptographic key. > ... > To create a client capable of using the JWT Bearer Grant Type mechanism with Ory, you can use the following CLI command: > ory create oauth2-client --project "$PROJECT_ID" \ > --name "Client Credentials Demo" \ > --grant-type client_credentials \ > --token-endpoint-auth-method private_key_jwt \ > --jwks-uri <https://example.org/path/to/clients/public_key_set.jwks>
> ... > When authenticating the client at the token endpoint, you generate and sign the JSON Web Token with the following claims: ... > [OAuth2 client credentials flow](https://www.ory.sh/docs/oauth2-oidc/client-credentials#jwt-bearer-profile-for-oauth2-client-authentication) Therefore, among the available options (client_secret_basic
, client_secret_post
, and private_key_jwt
), private_key_jwt
(JWT Bearer profile) is the most secure.