Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Not able to Access APIs with OAUTH2 authentication

NagspOct 15 2019 — edited Oct 16 2019

Hi ,

I am trying to access an API (third party URL -- end point URL ) by passing token key value(token value comes from other URL by passing client id and secret) pair in the header

In Postman i have no issues in accessing the UPI.

1)I am generating a bearer type token by passing client id and secret to the URL which generates token .

2)passing the acquired token to the end point URL and able to see the data from the end point URL.

but where as in apex , i tried to access the data from the end point URL in two ways , one by creating a web source module and other by calling the URL using apex_web_service.make_rest_request both are not fruitful.

please find the steps below

1)generate a token based on client id and secret

apex_web_service.oauth_authenticate(p_token_url     => URL_that_generates_token

                                     p_client_id     =>  client_id,

                                     p_client_secret => secret);

 

2)In header i have to pass two header variables

  apex_web_service.g_request_headers(1).name := 'Content-Type';

apex_web_service.g_request_headers(1).value := 'application/json';

apex_web_service.g_request_headers(2).name := 'Authorization';

apex_web_service.g_request_headers(2).value := 'Bearer ' || apex_web_service.g_oauth_token.token;

3)Making a call to the end point URL.

      l_resp := apex_web_service.make_rest_request(p_url => END_POINT_URL

          p_http_method => 'GET', 

          p_parm_name => l_parm_names, 

          p_parm_value => l_parm_values 

);

ERROR MESSAGE:

Technical Info (only visible for developers)

  • is_internal_error: false
  • ora_sqlcode: -20001
  • ora_sqlerrm: ORA-20001: Server responded with unsupported OAuth token type. ORA-06512: at "APEX_190100.WWV_FLOW_PROCESS_NATIVE", line 93 ORA-06512: at "APEX_190100.WWV_FLOW_DYNAMIC_EXEC", line 1500 ORA-06512: at "APEX_190100.WWV_FLOW_DYNAMIC_EXEC", line 2501 ORA-06512: at "APEX_190100.WWV_FLOW_WEB_SERVICES", line 573 ORA-06512: at "APEX_190100.WWV_FLOW_WEBSERVICES_API", line 512 ORA-06512: at line 16 ORA-06512: at "SYS.DBMS_SYS_SQL", line 2120 ORA-06512: at "SYS.WWV_DBMS_SQL_APEX_190100", line 599 ORA-06512: at "APEX_190100.WWV_FLOW_DYNAMIC_EXEC", line 2486 ORA-06512: at "APEX_190100.WWV_FLOW_DYNAMIC_EXEC", line 1476 ORA-06512: at "APEX_190100.WWV_FLOW_EXEC_LOCAL", line 2457 ORA-06512: at "APEX_190100.WWV_FLOW_EXEC", line 2503 ORA-06512: at "APEX_190100.WWV_FLOW_EXEC", line 2538 ORA-06512: at "APEX_190100.WWV_FLOW_PROCESS_NATIVE", line 76 ORA-06512: at "APEX_190100.WWV_FLOW_PROCESS_NATIVE", line 1153 ORA-06512: at "APEX_190100.WWV_FLOW_PLUGIN", line 2457
  • component.type: APEX_APPLICATION_PAGE_PROCESS

 

Thanks in advance

Nagarjuna

Comments
Post Details
Added on Oct 15 2019
10 comments
406 views