0

I am trying to setup a rest data source in APEX with the rest end point created in ORDS. The rest end points are secured with OAuth2- client credentials. In postman, I could get the access token from the OAuth end point using client id & secret and use it as bearer token in my API call without any issues.

However, I was not successful in setting the rest data source with OAuth2 authentication in APEX. Here are the steps i followed. (My APEX version is 22.1.4)

APEX:

  • Create Rest Data Source - from scratch

  • Rest Data Source Type -> Oracle Rest Data Source URL End Point: https://myserverpath/ords/demo/leave/getLeave

  • Base Path: https://myserverpath/ords/demo/ Service URL Path: leave/getLeave

  • Authentication Type: OAuth2 Client Credentials Flow OAuth Token URL: https://myserverpath/ords/demo/oauth/token

  • Client id: redacted

  • Client Secret:redacted

  • Discover: gives error "Discovery error: Oracle APEX cannot compute a data profile from the response data of type: text/html."

  • Selected "Create Rest Resource Manually"

  • Created a IG on the RDS turned debug on while running the IG and debug message below

Found token "ACCESS_TOKEN".

Access token still valid (expiry=2022-09-13 22:21:59)

begin_request p_url=>https://myserverpath/ords/demo/leave/getLeave?limit=51,p_method=>GET,p_proxy_override=>,p_transfer_timeout=>,p_https_host=>,p_wallet_path=>

Loading instance wallet

set_header Proxy-Connection: Keep-Alive

set_header Content-Type: application/vnd.oracle.resource+json;type=filter-form;charset=UTF-8

set_header User-Agent: Oracle APEX

set_header Authorization: ***

HTTP response 401 - Unauthorized

Curl Command that works:

curl --location --request GET 'https://myserverpath/ords/demo/leave/getLeave' --header 'Authorization: Bearer <bearer_token>'

Is there any step I am missing while setting up rest data source in APEX?

1 Answer 1

0

It looks like you're missing a space between

Bearer

and the token.

Sign up to request clarification or add additional context in comments.

3 Comments

hmmm ... this is an ORDS REST service, protected by OAuth2, correct? That should work just fine with APEX. Can you show the "curl" request to get the access token with Client ID and Client Secret, so that we can see whether there is anything special here? Also can you make sure that you copied and pasted the Client ID and Client Secret correctly in (including the typical two dots ("..") at the end ...?
@Carsten, please see my curl command below for the OAuth and access token curl -X POST 'https://<myserverpath>/ords/demo/oauth/token' -H "Content-Type: application/x-www-form-urlencoded" -u clientid:clientsecret -d 'grant_type=client_credentials' curl response: {"access_token":<readacted>,"token_type":"bearer","expires_in":3600}
As this is also discussed on the Oracle Discussion Forum, let's continue there: community.oracle.com/tech/developers/discussion/4503374/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.