AnnamariaL
AnnamariaL

Reputation: 251

Exchange token from AWS Cognito to AWS API Gateway

I'm preparing my degree thesis ( focuses on cloud computing ) so I'm a student and not expert at all my apologies if the question looks stupid.

I'm building a serverless architecture based on NodeJS and Javascript ( back-end and front-end ). I'd like to manage the user through AWS Cognito. I've configured my user pool and the GUI in order to register a user or allow the user to use an identity provider like Facebook or Google ( auth login ).

I'm stuck because after the user clicks on the Facebook login I'm able to retrieve the token in my callback page ( it looks like xxxx-xxxx-xxxx-xxxx ) but if I try to use that token as "Authorization" in the header in order to access to an API ( AWS API gateway ) I'm getting an unauthorized request.

I've understood that I need to exchange this token with a valid AWS identity token but I'm not able to understand how to do that in JS with AWS JS SDK.

I've found a couple of examples online that uses username and password, but if I don't have those data but just the token that comes from Facebook or Google how can I grab the AWS identity token?

I'll really appreciate if someone can help me!

Upvotes: 0

Views: 323

Answers (2)

AnnamariaL
AnnamariaL

Reputation: 251

I just give up :(

I did everything ( hosting + authentications + serverless functions + database ) in less than 1 hour with google Firebase.

Wasted 4 days trying to figuring out how to connect all the AWS services without success.

If you are looking for a fast and complete serverless solution I suggest to take look at Google Firebase.

Upvotes: 2

Dmitry Grinko
Dmitry Grinko

Reputation: 15204

If you want to use Facebook and Google with Amazon Web Services you should know about Amazon Cognito Federated Identities

Amazon Cognito Federated Identities enable you to create unique identities and assign permissions for users. Your identity pool can include:

  • Users in an Amazon Cognito user pool
  • Users who authenticate with federated identity providers such as Facebook, Google, or a SAML-based identity provider
  • Users authenticated via your own existing authentication process

Upvotes: 0

Related Questions