jwtEncode()
Returns an encoded JSON Web Token (JWT).
Synopsis
string jwtEncode(string payload, string key [, string algorithm ]);
Parameters
Parameter | Description |
---|---|
payload |
A valid JSON object. Note: The validity of the object is not checked by this
function.
|
key |
The encoding key. Note: It must be at least 32 characters long.
|
algorithm | The optional parameter to specify the signing algorithm used to
sign the JWT. The following values are supported (see also here):
The default value is "HS256" to stay backwards compatible. When
using "RSxxx" values, the key must contain a valid
private RSA key.
Note: Encoding a JWT without signing it
(i.e.: setting algorithm as "none") is not supported.
|
Return value
Encoded and signed token.
Description
The function jwtEncode() returns an encoded JWT token containing "payload", signed with "key". The parameter "payload" should contain a valid JSON object, but this is not checked by this function. "HS256" is used as the signing algorithm. If any problems are encountered (e.g:. the key being too short), an empty string is returned. The error details can be read with getLastError().
Assignment
File function
Availability
UI