Skip to main content
JWT_ENCODE

Encodes a JSON Web Token for usage with APIs

Updated over 2 weeks ago

Description

JWT_ENCODE() encodes a JSON Web Token using a specified algorithm, key, and payload, with an optional custom header.

Syntax

JWT_ENCODE(algorithm, key, payload_json_text, [header_json_text])

Output

text

Variables

  1. algorithm: The hashing algorithm to use (ex: HS256, HS384, HS512, and RS256, RS384, RS512).

  2. key: The secret key or private key for signing the token.

  3. payload_json_text: The JSON-formatted payload to include in the token.

  4. [header_json_text]: (Optional) A JSON-formatted header override.

Example

JWT_ENCODE('HS256', 'abcdefg', `payload`)

Payload

JWT_ENCODE

{"my":"payload"}

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJteSI6InBheWxvYWQifQ.Pyk2wIR5kCoXVdjQOJOasApbfJEL4PyipH2aZsF523Q

Did this answer your question?