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.

How to Call a OAUTH2 secured REST API using access token dynamically

SandipanAug 14 2024

HI Team,

I am trying to build a REST API in APEX with OAuth2 security. I am able to create roles, privilages and clients and associate them to secure the API.

Calling of the API from Postman, requires 2 steps:

First, get the Access Token by calling the the standard REST API using the Client ID and Client Secrets

https://<Host Name>/ords/wksp_billingworkspace/oauth/token

{

"access\_token": "xxxxxxxxxxxxxxxx",

"token\_type": "bearer",

"expires\_in": 3600

}

Second, Call the actual REST API and pass the Access Token from previous call as Bearer token.

https://<Host Name>/ords/wksp_billingworkspace/ccm/company/:company_id

This way it works fine. But, we need to provide this API to external application who will eventually call from their applications.

My question, is can we merge above two steps in one step? i.e, Can we accomodate the Access Token retrival in the main REST API call itself and use it as Bearer Token?

Thanks

Sandipan

Comments
Post Details
Added on Aug 14 2024
9 comments
164 views