Get a JSON Web Token (JWT) ​
Learn how to get a JSON Web Token (JWT), which you can use to access secured endpoints.
Prerequisites ​
You use an OpenID Connect-compliant (OIDC-compliant) identity provider.
Steps ​
Create an application in your OIDC-compliant identity provider. Save the client credentials: Client ID and Client Secret.
In the URL
https://{YOUR_IDENTITY_PROVIDER_INSTANCE}/.well-known/openid-configurationreplace{YOUR_IDENTITY_PROVIDER_INSTANCE}with the name of your OIDC-compliant identity provider instance. Then, open the link in your browser. Save the values of the token_endpoint, jwks_uri, and issuer parameters.Export the saved values as environment variables:
bashexport CLIENT_ID={YOUR_CLIENT_ID} export CLIENT_SECRET={YOUR_CLIENT_SECRET} export TOKEN_ENDPOINT={YOUR_TOKEN_ENDPOINT}Encode your client credentials and export them as an environment variable:
bashexport ENCODED_CREDENTIALS=$(echo -n "$CLIENT_ID:$CLIENT_SECRET" | base64)To obtain a JWT, run the following command:
bashcurl -X POST "$TOKEN_ENDPOINT" -d "grant_type=client_credentials" -d "client_id=$CLIENT_ID" -H "Content-Type: application/x-www-form-urlencoded" -H "Authorization: Basic $ENCODED_CREDENTIALS"