11.2 CREATE_CREDENTIAL Procedure

This procedure creates a credential definition.

Syntax

PROCEDURE CREATE_CREDENTIAL (
    p_credential_name       IN VARCHAR2,
    p_credential_static_id  IN VARCHAR2,
    p_authentication_type   IN VARCHAR2,
    p_scope                 IN VARCHAR2         DEFAULT NULL,
    p_allowed_urls          IN apex_t_varchar2  DEFAULT NULL,
    p_prompt_on_install     IN BOOLEAN          DEFAULT FALSE,
    p_credential_comment    IN VARCHAR2         DEFAULT NULL );

Parameters

Table 11-2 CREATE_CREDENTIAL Parameters

Parameter Description
p_credential_name The credential name.
p_credential_static_id The credential static ID.
p_authentication_type

The authentication type. Supported types:

  • apex_credential.C_TYPE_BASIC
  • apex_credential.C_TYPE_OAUTH_CLIENT_CRED
  • apex_credential.C_TYPE_JWT
  • apex_credential.C_TYPE_OCI
  • apex_credential.C_TYPE_HTTP_HEADER
  • apex_credential.C_TYPE_HTTP_QUERY_STRING
p_scope (Optional) OAuth 2.0 scope.
p_allowed_urls (Optional) List of URLs (as APEX_T_VARCHAR2) that these credentials can access.
p_prompt_on_install (Optional) Choose whether prompts for this credential should be displayed when the application is being imported on another Oracle APEX instance.
p_credential_comment (Optional) Credential comment.

Example

The following example creates a credential definition "OAuth Login."

BEGIN
   -- first set the workspace
   apex_util.set_workspace(p_workspace => 'MY_WORKSPACE');

   apex_credential.create_credential (
       p_credential_name => 'OAuth Login',
       p_credential_static_id => 'OAUTH_LOGIN',
       p_authentication_type => apex_credential.C_TYPE_OAUTH_CLIENT_CRED,
       p_scope => 'email',
       p_allowed_urls => apex_t_varchar2( 'https://tokenserver.mycompany.com/oauth2/token', 'https://www.oracle.com' ),
       p_prompt_on_install => false,
       p_credential_comment => 'Credential for OAuth Login' );

  -- should be followed by set_persistent_credentials
  apex_credential.set_persistent_credentials (
      p_credential_static_id => 'OAUTH_LOGIN',
      p_client_id => 'dnkjq237o8832ndj98098-..',
      p_client_secret => '1278672tjksaGSDA789312..' );
END;