2

For a React-Native application I would like to send Cognito credentials with a GET request to my API. I'm following the following approach [1]:

Cognito UserPool + Cognito Identity Pool + API Gateway + AWS_IAM Authorization + Cognito Credentials

At this current stage I can receive Cognito credentials for the associated role as explained here [2] Now, I would like to use these credentials to access my API. I have set the Authorization Type to AWS_IAM in my API Gateway. But I have no idea HOW i could send my Cognito credentials with my GET request. I have plowed through the documents, but it seems that it only explains the different SDKs.

let response = await fetch('https://12345.execute-api.us-east-1.amazonaws.com/dev/single', {
  headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json',
          // What to do here??
        },

Any pointers and or documentation I could look at?

[1] https://forums.aws.amazon.com/thread.jspa?threadID=230452

[2] http://mobile.awsblog.com/post/TxGNH1AUKDRZDH/Announcing-Your-User-Pool-in-Amazon-Cognito

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
swennemen
  • 945
  • 1
  • 14
  • 24
  • 2
    See http://stackoverflow.com/questions/28479138/how-can-one-make-authenticated-requests-with-aws-cognito-from-mobile-to-aws-serv – jarmod May 07 '16 at 20:02

1 Answers1

0

I do not fully understand what you mean by sending your Cognito credential to API Gateway, but if you want to use the credential you get from Cognito, you need to use that credential to sign the request to API Gateway.

I suggest you can use the signer in AWS react native SDK to sign the request or some 3rd parties library like react-native-aws-signature

Ka Hou Ieong
  • 5,835
  • 3
  • 20
  • 21