8.4 SET_PERSISTENT_TOKEN Procedure

This procedure uses an autonomous transaction in order to store the token in the database table.

Stores a token into a credential store which is obtained with manual or custom PL/SQL code. The credential store saves this token in encrypted form for subsequent use by APEX components. The token is stored for the lifetime of the APEX session. Other sessions cannot use this token. When tokens are obtained with custom PL/SQL code, Client ID, and Client Secret are not stored in that credential store – it contains the tokens set by this procedure only.

Syntax

procedure set_persistent_token(
    p_credential_static_id in varchar2,
    p_token_type           in t_token_type,
    p_token_value          in varchar2,
    p_token_expires        in date );

Parameters

Table 8-4 SET_PERSISTENT_TOKEN Procedure Parameters

Parameters Description

p_credential_static_id

The credential static ID.

p_token_type

The token type: APEX_CREDENTIAL.C_TOKEN_ACCESS, APEX_CREDENTIAL.C_TOKEN_REFRESH or APEX_CREDENTIAL.C_TOKEN_ID.

p_token_value

The value of the token.

p_token_expiry

The expiry date of the token

Example

The following example stores OAuth2 access token with value sdakjjkhw7632178jh12hs876e38.. and expiry date of 2017-10-31 into credential OAuth Login.

begin
     apex_credential.set_session_token (
     p_credential_static_id => 'OAuth Login',
     p_token_type           => apex_credential.C_TOKEN_ACCESS,
     p_token_value          => 'sdakjjkhw7632178jh12hs876e38..',
     p_token_expiry         => to_date('2017-10-31', 'YYYY-MM-DD') );
end;