16.3 CREATE_CREDENTIAL Procedure Signature 2

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,
    --
    p_db_credential_name        IN VARCHAR2         DEFAULT NULL,
    p_db_credential_is_instance IN BOOLEAN          DEFAULT NULL )

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 OAuth 2.0 scope.
p_allowed_urls List of URLs (as APEX_T_VARCHAR2) that these credentials can access.
p_db_credential_name Name of the database credential to be referenced.
p_db_credential_is_instance Whether the database credential was made available at the Oracle APEX instance level (all workspaces). This parameter can only be used when instance credentials are enabled for the APEX instance using the INSTANCE_DBMS_CREDENTIAL_ENABLED instance parameter.
p_prompt_on_install Choose whether prompts for this credential should be displayed when the application is being imported on another APEX instance.
p_credential_comment Credential comment.

Example

The following example creates a new web credential "OAuth Login."

BEGIN
    -- 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' );

     -- store client ID and client secret into the credential
    apex_credential.set_persistent_credentials (
        p_credential_static_id  => 'OAUTH_LOGIN',
        p_client_id             => 'dnkjq237o8832ndj98098-..',
        p_client_secret         => '1278672tjksaGSDA789312..' );
END;