Start Free
SonarQube Community Build | Server installation and setup | Pre-installation steps | JWT token

Generating a JWT token

By default, users are logged out and sessions closed when server is restarted.  If you prefer keeping user sessions open, a secret should be defined. Value is HS256 key encoded with base64. It must be unique for each installation of SonarQube Server. 

The following examples illustrate how to generate a HS256 key encoded with base64, where your_secret and your_key are arbitrary strings that can be modified.

$message = 'your_secret'
$secret = 'your_key'

$hmacsha = New-Object System.Security.Cryptography.HMACSHA256
$hmacsha.key = [Text.Encoding]::ASCII.GetBytes($secret)
$signature = $hmacsha.ComputeHash([Text.Encoding]::ASCII.GetBytes($message))
$signature = [Convert]::ToBase64String($signature)

echo $signature
echo -n "your_secret" | openssl dgst -sha256 -hmac "your_key" -binary | base64

Was this page helpful?

© 2008-2025 SonarSource SA. All rights reserved.

Creative Commons License