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,
    p_named_scopes              IN VARCHAR2         DEFAULT NULL,
    p_referenced_static_id      IN VARCHAR2         DEFAULT NULL,
    p_oauth_token_request_type  IN VARCHAR2         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
  • APEX_CREDENTIAL.C_TYPE_OAUTH_PASSWORD
  • APEX_CREDENTIAL.C_TYPE_SIGNED_USER_ASSERTION
  • APEX_CREDENTIAL.C_TYPE_USER_ASSERT_CERTIFICATE
p_scope OAuth 2.0 scope to use when making token requests.
p_allowed_urls List of URLs (as APEX_T_VARCHAR2) that these credentials can access.
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.
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_named_scopes  
p_referenced_static_id

Reference to another credential. Only allowed for authentication type:

  • APEX_CREDENTIAL.C_TYPE_OAUTH_PASSWORD referencing an apex_credential.c_type_basic
  • APEX_CREDENTIAL.C_TYPE_SIGNED_USER_ASSERTION referencing an apex_credential.c_type_user_assert_certificate
p_oauth_token_request_type

Authenticating method used for making a request to an OAuth2 token URL.

Supported methods:

  • C_OAUTH_TOKEN_REQT_BODY
  • C_OAUTH_TOKEN_REQT_BASIC
  • C_OAUTH_TOKEN_REQT_CLIENT_ID
  • C_OAUTH_TOKEN_REQT_BASIC_CLID

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;