35.12 OAUTH_AUTHENTICATE Function

This function performs OAUTH autentication and requests an OAuth access token. The token and its expiry date are stored in the global variable g_oauth_token.

type oauth_token is record(
     token      varchar2(255),
     expires    date );

Note:

Currently only the Client Credentials flow is supported.

Syntax

APEX_WEB_SERVICE.OAUTH_AUTHENTICATE(
    p_token_url         in varchar2,
    p_client_id         in varchar2,
    p_client_secret     in varchar2,
    p_flow_type         in varchar2 default OAUTH_CLIENT_CRED,
    p_proxy_override    in varchar2 default null,
    p_transfer_timeout  in number   default 180,
    p_wallet_path       in varchar2 default null,
    p_wallet_pwd        in varchar2 default null,
    p_https_host        in varchar2 default null );

Parameters

Table 35-7 OAUTH_AUTHENTICATE Function Parameters

Parameter Description

p_token_url

The url endpoint of the OAuth token service.

p_client_id

OAuth Client ID to use for authentication.

p_client_secret

OAuth Client Secret to use for authentication.

p_flow_type

OAuth flow type - only OAUTH_CLIENT_CRED is supported at this time.

p_proxy_override

The proxy to use for the request.

p_transfer_timeout

The amount of time in seconds to wait for a response.

p_wallet_path

The filesystem path to a wallet if request is https. For example, file:/usr/home/oracle/WALLETS.

p_wallet_pwd

The password to access the wallet.

p_https_host

The host name to be matched against the common name (CN) of the remote server's certificate for an HTTPS request.

Example

begin
    apex_web_service.oauth_authenticate(
        p_token_url     => '[URL to ORDS OAuth troken service: http(s)://{host}:{port}/ords/.../oauth/token]',
        p_client_id     => '[client-id]',
        p_client_secret => '[client-secret]');
end;