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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

apex_web_service.make_rest_request with token URL returning Unauthorized error

SandipanFeb 4 2025

We are trying to make a REST call to an external system using apex_web_service.make_rest_request following the OAUTH2 authentication method, which is deployed in AWS. We have got a Token URL (Login URL) and Original API URLs to fetch the actual business data with Bearer token authentication.
When we are following two step authentication in our code, i.e, fetching the token from Token URL using Basic Authentication and supplying the token to call the main API URLs by setting the Authorization header it is working fine and we get the results.
But when we are trying to pass the Token URL along with the username/passwords to make_rest_request call to main URL, the result is returning Unauthorized error.
When we try to call oauth_authenticate for token URL, it is returning unauthorized error as well.

The credential we have initially using as Basic Authentication and checked the logs at target system. It was showing that make_rest_request is making a call to the actual API URL with basic authentication, which is not valid.

Then we changed the credential type to OAUTH2.0 flow and checked the logs in target system. We see now, it is calling the Token URL with necessary parameters set with basic authentication, the response shows Access Tokens are returned. But, it's not further proceeding to call the actual API URL with Bearer Authorization.

Attached are some sample files that we tried.

Thanks

Sandipan

AWS Log token URL with Basic Auth Cred.txt

AWS Log token URL with OAUTH2 Cred.png

oauth_authenticate call.txt

Toekn URL Script with OAUTH2 Cred.txt

Two step token retrieve.txt

Comments
Post Details
Added on Feb 4 2025
0 comments
54 views