I am trying to get the OKTA logged in user details using the OKTA api v1/users/me in plsql code.
I have used the apex_web_service.make_rest_request to access the API.
I am getting an JSON error response when access the api from plsql code. But when I try to access the API directly from the browser I am able to get the user details as JSON.
Hello,
This endpoint relies on the session cookie to be set. Depending on the error you are receiving the apex_web_service.make_rest_request may not be sending the sid cookie. If this does not seem to be the issue please attach the error response being received.
I have logged in to OKTA, but I wanted to use the same sign on from the Oracle Apex application.
I have tried to create an Open ID application in OKTA for the Apex application and use the same ID in the APex. but it doesn’t get connected.
I have not worked with Oracle Apex. I assume you are logging into Okta in a browser session, then opening another tab and accessing the Apex application and attempting this call? Or are you using the Okta Access Gateway with Apex? Please detail the steps you are attempting and the exact setup you are using.
For this /me endpoint, either the browser or Apex in this case needs to send the Okta session cookie. Another option would be to send an API token of a user. The link I included documents this.
From looking at the Apex doc for this call, I assume that you would either need to set cookie with your Okta session id, or set the Authorization: SSWS header with an API token of an Okta administrator account.
The API token is associated with the admin who generated it, but it will not be tied to a specific application. Steps for how to create/use one can be found here.
If you include the SSWS in this request, you will always get information about the user who was issued the API key. If you instead rely on the user’s session token in browser and make a CORS request without the authorization header, you will instead get information back about the user logged in on the browser.