This function encodes and optionally encrypts payload.
Syntax
function encode (
     p_iss           in varchar2                 default null,
     p_sub           in varchar2                 default null,
     p_aud           in varchar2                 default null,
     p_nbf_ts        in timestamp with time zone default null,
     p_iat_ts        in timestamp with time zone default systimestamp,
     p_exp_sec       in pls_integer              default null,
     p_jti           in varchar2                 default null,
     p_other_claims  in varchar2                 default null,
     p_signature_key in raw                      default null )
     return varchar2
Parameters
Table 20-2 ENCODE Function Parameters
| Parameter | Description | 
|---|---|
| 
 | Optional  | 
| 
 | Optional  | 
| 
 | Optional  | 
| 
 | Optional  | 
| 
 | Optional  | 
| 
 | Optional  | 
| 
 | Optional  | 
| 
 | Optional raw JSON with additional claims. | 
| 
 | Optional MAC key for the signature. If not null, a  | 
Returns
A varchar2, the encoded token value.
Example
This example creates and prints a JWT value for Example User, intended to be used by Example JWT Recipient. The token is valid for 5 minutes.
declare
    l_jwt_value varchar2(32767);
begin
    l_jwt_value := apex_jwt.encode (
                       p_iss => 'Example Issuer',
                       p_sub => 'Example User',
                       p_aud => 'Example JWT Recipient',
                       p_exp_sec => 60*5,
                       p_other_claims => '"name1": '||apex_json.stringify('value1')||
                                         ',"name2": '||apex_json.stringify('value2'),
                       p_signature_key => ... encryption key ... );
    sys.dbms_output.put_line(l_jwt_value);
end;
Parent topic: APEX_JWT