Home > Blockchain >  Access AWS API Gateway method using Cognito Identity pool for unauthorized users using Amplify SDK f
Access AWS API Gateway method using Cognito Identity pool for unauthorized users using Amplify SDK f

Time:01-04

I want to make a request from a React (Next JS) frontend to an AWS API Gateway endpoint that allows unauthorized access via an AWS Cognito identity pool. I'm using AWS Amplify SDK (Auth) for Javascript on the front end. For an authorized user I can use Auth.currentSession which returns a session object. The object contains a method to get a JWT token that can be passed to the Authorization header. But for an unauthorized user, I can use only Auth.currentCredentials which return credentials object. That object doesn't contain a method to get the JWT token, so I don't understand what should I pass to headers to make a request to my endpoint.

How can I invoke the API gateway's method for unauthorized users using AWS Amplify Javascript SDK?

CodePudding user response:

I found AWS Amplify Signer that can be used to create required headers from the credentials object.

  • Related