20.4 VALIDATE Procedure

This procedure validates the given token.

Syntax

procedure validate (
     p_token          in t_token,
     p_iss            in varchar2    default null,
     p_aud            in varchar2    default null,
     p_leeway_seconds in pls_integer default 0 );

Parameters

Table 20-4 VALIDATE Procedure Parameters

Parameter Description

p_token

The JWT.

p_iss

If not null, verify that the "iss" claim equals p_iss.

p_aud

If not null, verify that the single "aud" value equals p_aud. If "aud" is an array, verify that the "azp" (Authorized Party) claim equals p_aud. This is an OpenID extension.

p_leeway_seconds

Fudge factor (in seconds) for comparing "exp" (Expiration Time), "nbf" (Not Before) and "iat" (Issued At) claims.

Raises

APEX.ERROR.INTERNAL: Validation failed, check debug log for details.

Example

Verify that l_value is a valid OpenID ID token.

declare
     l_value varchar2(4000) := 'eyJ0 ... NiJ9.eyJ1c ... I6IjIifX0.DeWt4Qu ... ZXso';
     l_oauth2_client_id varchar2(30) := '...';
     l_token apex_jwt.t_token;
begin
     l_token := apex_jwt.decode (
                    p_value => l_value );
     apex_jwt.validate (
         p_token => l_token,
         p_aud => l_oauth2_client_id );
end;