Skip to content

Authenticate with Private Key JWT

In this tutorial, you’ll learn how to use Private Key JWT to authenticate your OAuth client application to Qlik Cloud securely.

Instead of sharing a client secret, your application signs authentication requests with a private key, and Qlik Cloud validates them using your registered public key.

This approach is more secure and ideal for production environments.

What you’ll learn

  • How to generate a public/private key pair for OAuth authentication
  • How to register your public key with an OAuth client in Qlik Cloud
  • How to sign JWT assertions and request access tokens
  • How to use tokens to authenticate API requests

Prerequisites

  • A Qlik Cloud tenant with Tenant Admin access
  • OpenSSL installed on your development machine
  • A programming language with JWT signing libraries (JavaScript with jose or Python with PyJWT recommended)

How it works

Private Key JWT lets your application prove its identity using asymmetric cryptography instead of a shared secret:

  1. You generate a public/private key pair and register the public key with your OAuth client in Qlik Cloud
  2. Your application creates a JWT (JSON Web Token) signed with its private key
  3. Your application sends the signed JWT to Qlik Cloud’s token endpoint
  4. Qlik Cloud validates the signature using your registered public key and returns an access token
  5. Your application uses the access token for API requests

The private key never leaves your application, making this approach more secure than sharing a client secret.

Step 1: Generate your key pair

Generate a public/private key pair that will be used to sign the JWT assertion and register the public key with your OAuth client.

Use OpenSSL to generate a 2048-bit RSA key pair (minimum requirement for RS256):

Terminal window
openssl genrsa -out private_key.pem 2048
openssl rsa -in private_key.pem -pubout -out public_key.pem
Warning

Keep your private key (private_key.pem file) secure and never share it. It is used to sign JWT assertions.

Convert the public key from PEM to JSON Web Key (JWK) format using the jose package:

Save the JWK output. You’ll register it with your OAuth client in the next step.

Tip

For other algorithms (RS512, ES384), see Supported algorithms in the reference.

Step 2: Create and configure your Web OAuth client

Now that you have your public key in JWK format, create a new Web OAuth client and register it.

  1. In the Administration activity center, go to OAuth.

  2. Click Create new and select Web as the client type.

  3. Enter a name.

  4. Under Authentication method, select Private Key JWT.

  5. Paste your JWK (from Step 1) into the Public key field.

    Warning

    Paste only the public key in JWK format. Never upload or share your private key.

  6. Click Create.

  7. Set the consent method to Trusted (click the action menu and select Change consent method).

Your OAuth client is now configured for Private Key JWT authentication. Copy your Client ID for use in the next step. Qlik Cloud will validate JWT signatures against this public key during token requests.

Step 3: Request an access token

Private Key JWT authentication requires two sub-steps: generate a signed JWT assertion, then exchange it for a token.

Generate the JWT assertion

Use your private key to create a signed JWT assertion:

Copy the output (your signed JWT assertion). You’ll use this in Step 2.

Exchange the assertion for a token

Send your JWT assertion to the Qlik Cloud token endpoint. Use one of the methods below:

A successful response returns your access token:

{
"access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
"token_type": "Bearer",
"expires_in": 3600,
"scope": "user_default"
}

Use the token in API requests

Add your access token to the Authorization header:

Troubleshooting

IssueCauseSolution
Signature validation failedPublic key doesn’t match private key or algorithm mismatchVerify the algorithm in JWT header (alg) matches your registered key (RS256, RS512, ES384). Regenerate and re-register the key pair if needed.
Invalid audienceaud claim doesn’t match token endpoint URLEnsure aud is exactly https://<TENANT>.qlikcloud.com/oauth/token with no trailing slashes
Invalid client or unauthorized_clientiss/sub claims don’t match CLIENT_ID or client doesn’t existVerify both iss and sub are set to your actual CLIENT_ID. Confirm the OAuth client exists and is enabled.
unsupported_client_assertion_typeWrong parameter valueEnsure client_assertion_type is exactly urn:ietf:params:oauth:client-assertion-type:jwt-bearer
Token request timeoutNetwork issue or tenant unreachableVerify network connection and test tenant URL: curl https://<TENANT>.qlikcloud.com

For detailed troubleshooting and security recommendations, see Private Key JWT reference.

Next steps

Was this page helpful?