16.10 SET_PERSISTENT_TOKEN Procedure

This procedure sets a token into the provided credential persistently, beyond the current Oracle APEX session. The token is encrypted for security. Client ID and Client Secret are not stored in the credential store by this procedure.

Syntax

APEX_CREDENTIAL.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,
    p_token_scope           IN   VARCHAR2         DEFAULT NULL );

Parameters

Parameters Description
p_credential_static_id The credential static ID.
p_token_type One of the constants C_TOKEN_ACCESS, C_TOKEN_REFRESH, or C_TOKEN_ID.
p_token_value The token value.
p_token_expires The token expiry date.
p_token_scope OAuth scope this token is valid for. Separate multiple scopes with blanks. If not provided, the Web Credential's default scope is assumed.

Example

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

begin
    apex_credential.set_persistent_token (
        p_credential_static_id => 'OAuth Login',
        p_token_type           => apex_credential.c_token_access,
        p_token_value          => 'sdakjjkhw7632178jh12hs876e38..',
        p_token_expires        => to_date('2023-10-31', 'YYYY-MM-DD'),
        p_token_scope          => 'profile email' );
end;