UnknownOperationException when posting to InitiateAuth from Oracle RDS DB

0

Hi folks,

I am trying to integrate with AWS Cognito from an oracle RDS database.

I know I will need to SIGV4 my content to post, but firstly I just want to try and call the REST API.

I have set up headers for X-Amz-Target and Content-Type but always get the response:

{"__type":"UnknownOperationException"}

Any advice/guidance appreciated.

Here is the code below:

begin
l_body := '{
"AuthFlow":"USER_PASSWORD_AUTH",
"AuthParameters":{
"USERNAME":"x",
"PASSWORD":"x"
},
"ClientId":"x",
"UserPoolId":"x"
}';

apex_web_service.g_request_headers.delete();

apex_web_service.g_request_headers(1).name := 'X-Amz-Target';
apex_web_service.g_request_headers(1).value := 'AWSCognitoIdentityProviderService.InitiateAuth';
apex_web_service.g_request_headers(1).name := 'Content-Type';
apex_web_service.g_request_headers(1).value := 'application/x-amz-json-1.1';

l_clob := apex_web_service.make_rest_request(
p_url => 'https://cognito-idp.eu-west-2.amazonaws.com/',
p_http_method => 'POST',
p_wallet_path => 'file:///rdsdbdata/userdirs/01',
p_body => l_body);

dbms_output.put_line('Response = '||l_clob);

end;
/

asked 4 years ago807 views
1 Answer
0

We typically get this error only when 'X-Amz-Target' doesn't have a valid value. I see that in the above code, both 'X-Amz-Target' & 'Content-Type' are being set with the same index for g_request_headers() i.e. 1. From what I saw in Oracle community threads and 3rd party posts, g_request_headers for different headers have different values like g_request_headers(1), g_request_headers(2):
https://community.oracle.com/thread/4027920
https://stackoverflow.com/questions/45714313/getting-response-headers-from-apex-web-service-response-with-pl-sql
Could you try the same and see if this fixes your issue?

AWS
SUPPORT ENGINEER
answered 4 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions