Operations (sample payloads)

Main operations
Copy

Sign
Copy

Sign a JSON web token using a secret.

Sample Input

1
{
2
"payload": {
3
"userId": "12345",
4
"username": "johndoe",
5
"role": "admin"
6
},
7
"key": "mySecretKey123",
8
"options": {
9
"algorithm": "HS256",
10
"expiresIn": "1h",
11
"issuer": "https://myapp.com",
12
"audience": "https://api.myapp.com"
13
}
14
}

Sample Output

1
{
2
"result": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxMjM0NSIsInVzZXJuYW1lIjoiam9obmRvZSIsInJvbGUiOiJhZG1pbiIsImlhdCI6MTYyMzI1NjAwMCwiZXhwIjoxNjIzMjU5NjAwLCJpc3MiOiJodHRwczovL215YXBwLmNvbSIsImF1ZCI6Imh0dHBzOi8vYXBpLm15YXBwLmNvbSJ9.1234567890abcdefghijklmnopqrstuvwxyz"
3
}

Verify
Copy

Verify a JSON web token using a secret.

Sample Input

1
{
2
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
3
"key": "your-256-bit-secret",
4
"options": {
5
"algorithms": [
6
"HS256"
7
],
8
"audience": [
9
"https://api.example.com"
10
],
11
"issuer": [
12
"https://issuer.example.com"
13
],
14
"ignoreExpiration": false,
15
"subject": "user123",
16
"clockTolerance": 30,
17
"maxAge": "2h"
18
}
19
}

Sample Output

1
{
2
"result": {
3
"sub": "1234567890",
4
"name": "John Doe",
5
"iat": 1516239022
6
}
7
}