Operations (sample payloads)

Main operations

Sign

Sign a JSON web token using a secret. Sample Input

{
    "payload": \{
        "userId": "12345",
        "username": "johndoe",
        "role": "admin"
    \},
    "key": "mySecretKey123",
    "options": \{
        "algorithm": "HS256",
        "expiresIn": "1h",
        "issuer": "https://myapp.com",
        "audience": "https://api.myapp.com"
    \}
}

Sample Output

{
    "result": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxMjM0NSIsInVzZXJuYW1lIjoiam9obmRvZSIsInJvbGUiOiJhZG1pbiIsImlhdCI6MTYyMzI1NjAwMCwiZXhwIjoxNjIzMjU5NjAwLCJpc3MiOiJodHRwczovL215YXBwLmNvbSIsImF1ZCI6Imh0dHBzOi8vYXBpLm15YXBwLmNvbSJ9.1234567890abcdefghijklmnopqrstuvwxyz"
}

Verify

Verify a JSON web token using a secret. Sample Input

{
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
    "key": "your-256-bit-secret",
    "options": \{
        "algorithms": [
            "HS256"
        ],
        "audience": [
            "https://api.example.com"
        ],
        "issuer": [
            "https://issuer.example.com"
        ],
        "ignoreExpiration": false,
        "subject": "user123",
        "clockTolerance": 30,
        "maxAge": "2h"
    \}
}

Sample Output

{
    "result": \{
        "sub": "1234567890",
        "name": "John Doe",
        "iat": 1516239022
    \}
}

Was this page helpful?