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!

Getting Unauthorized when trying to obtain token from OAuth2.0 (ORDS 3.0.6)

Hawk333Sep 15 2016 — edited Sep 21 2016

I am trying to implement Two-legged OAuth2 following this tutorial: http://www.cloudnueva.com/blog/archives/08-2016

I am using ORDS 3.0.6. I managed to follow the instructions up to 'Obtaining An Authorization Token' where I keep getting ' 401 Unauthorized'.

Here are my steps (from schema called 'AUDIT'):

--Enable schema:

BEGIN

ORDS.ENABLE_SCHEMA(

   TRUE,

   'AUDIT');

END;

/

--Define module

begin

ORDS.define_module(

   'v1',

   'v1/');

END;

/

--define template

BEGIN

ords.define_template(

      'v1',

      'customer/');

END;

/

--define handler:

BEGIN

ORDS.define_handler(

      'v1',

      'customer/',

      'GET',

      ords.source_type_collection_feed,

      'SELECT 1 from dual');

      commit;

END;

/

I can call the service successfully using 'https://example.com/ords/audit/v1/customer'

Then I continue with the steps as follows:

--Create privilege:

begin

  ords.create_privilege(

      p_name => 'audit.customer',

      p_role_name => NULL,

      p_label => 'Customer Service Privilege',

      p_description => 'Provide access to the customer service');

  COMMIT;

END;

/

--Create validation mapping:

begin

ords.create_privilege_mapping(

      p_privilege_name => 'audit.customer',

      p_pattern => '/v1/customer');  

  commit;

end;

/

--I run validation queries on both tables 'user_ords_privileges' and 'user_ords_privilege_mappings', and they return correct result

--Create new client:

begin

oauth.create_client(

      p_name => 'ABC INC Sales System',

      p_description => 'Sales System for ABC INC.',

      p_grant_type => 'client_credentials',

      p_privilege_names => 'audit.customer',

      p_support_email => 'fred@abcinc.com');

commit;

END;

/

I ran the query below, and got the client id and secret:

select client_id,client_secret from user_ords_clients;

Now when I try to obtain a session token, (using Postman) I key in the client ID in the username field. And the client secret in the password field. I also add the pair (grant-type/client_credentials) to the body. When I try to send POST request, I get '401 Unauthorized'.

What could be wrong here? And is there any way to debug this?

Thank you

Comments

DeloitteRob

yes this does not work and I have not been able to get this to work any way yet either.

Pradeep Kumar-Oracle

Hello, Just checking if anyone got a solution to this ?

Pradeep Kumar-Oracle

Just to update on this, I tried with "FullName" instead and it worked.
So, the call should be as below -

GET "https://<host>:<port>/hcmRestApi/resources/11.13.18.05/workers?q=FullName='Doe, Mic'"
user-uxa13

This is very frustrating. The documentation for worker api STILL (18 months later) has incorrect examples of how to retrieve a worker.

The employee api is being deprecated and we need to move everything over to the worker api. Oracle is making this job much more work than it needs to be by publishing incorrect documentation.

I hope they fix it.

Thank you @pradeep-kumar-oracle2 for your fix!!

Martin...
Answer

Hello,

I've just tried this query again …

GET "https://<host>:<port>/hcmRestApi/resources/latest/workers?q=names.LastName='Jones'"

And it is now working :-)

200 OK
{
	"items": [
		{
			"PersonId": 300000052307100,
			"PersonNumber": "1200243",
			...
			...
			},
			"names": {
				"items": [
					{
						"PersonNameId": 300000052307101,
						"EffectiveStartDate": "2021-11-24",
						"EffectiveEndDate": "4712-12-31",
						"LegislationCode": "GB",
						"LastName": "Jones",
						...
						...
}

Thank you for the fix

Marked as Answer by Martin... · Feb 3 2024
1 - 5
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Oct 19 2016
Added on Sep 15 2016
1 comment
865 views