Skip to Main Content

ORDS, SODA & JSON in the Database

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!

OAuth 2 token getting error 401 unauthorized even after providing right credentials and token URL (ORDS REST API)

Adnan3114Dec 19 2024 — edited Dec 30 2024

In the restful services I created custom role (named "client_auth_custom") and assigned that to a module through privilege (also named "client_auth_custom"). The API Module URL is: https://[host]/ords/webapp/mod/emp Then I created an OAuth client from PL/SQL:

BEGIN
    OAUTH.CREATE_CLIENT (p_name              => 'client_user',
                         p_grant_type        => 'client_credentials',
                         p_support_email     => 'test@abc.com',
                         p_description       => 'oauth client user',
                         p_privilege_names   => 'client_auth_custom');

    OAUTH.GRANT_CLIENT_ROLE (p_client_name   => 'client_user',
                             p_role_name     => 'client_auth_custom');
    COMMIT;
END;

I got the client id and secret from:

SELECT * FROM USER_ORDS_CLIENTS where name = 'client_user';

When I am trying to get token from postman through this URL https://[host]/ords/webapp/oauth/token I am getting Error: Could not complete OAuth 2.0 token request with Error 401--Unauthorized error. The software is running on weblogic server, running on HTTPS and not HTTP. We are using NGINX for proxy pass.

If the same API is used without any authentication it works without issue. I have also disabled the Enable SSL certificate verification option in postman

APEX Version: 24.1.0
ORDS Version: 24.2.3.r2011847
Weblogic Version: 14.1.1

Comments
Post Details
Added on Dec 19 2024
3 comments
783 views