11.11 SET_SESSION_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_SESSION_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 11-9 SET_SESSION_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_expires

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_expires         => to_date('2017-10-31', 'YYYY-MM-DD') );
end;