aws-cognito-angular-quickstart icon indicating copy to clipboard operation
aws-cognito-angular-quickstart copied to clipboard

Sending the authentication details to node js Serverless API

Open khaledshamat opened this issue 5 years ago • 6 comments

First of all, I would like to thank you for the great implementation, its very easy to play around with it and its readable, so I wanted to add some extra function to make a request to my secured Serverless API, which has the following configurations in the Serverless.yml file: functions: get: # Defines an HTTP API endpoint that calls the main function in get.js # - path: url path is /orders/{id} # - method: GET request handler: src/orders/get.main events: - http: path: orders/{id} method: get cors: true authorizer: aws_iam

but every time the request is sent I get the following on my api cloud watch logs:

error: Object message: "Missing Authentication Token"

Any advice please?

khaledshamat avatar Mar 01 '19 16:03 khaledshamat

You need to sign all API requests using sigv4. You can use amplify to do that https://aws-amplify.github.io/amplify-js/ Note, this repo was created before Amplify Cognito support. I would not use it as of 2019.

mordka avatar Apr 02 '19 14:04 mordka

@mordka Thanks for your hint. I actually also forked this project some time ago to build an application around it, but now heard multiple times it's no longer the recommended way to use Cognito in client side code. Can you recommend a similar Angular project based on Amplify that would will the gap and already and already covers a basic use cases? Sure, the docs are comprehensive, but some may not want to start from scratch, myself included :-)

tillkuhn avatar Jun 12 '19 09:06 tillkuhn

I can't recommend any good bootstrapping project in Amplify. There are some resources here: https://github.com/dabit3/awesome-aws-amplify but you can see Angular is not popular. I would recommend starting from scratch for deeper understanding of the underlying services. From my experience working with Amplify is not a seamless experience, mainly because their team tries to catch many birds with one shot.

mordka avatar Jun 12 '19 10:06 mordka

@tillkuhn. Can you please provide any links why "it's no longer the recommended way to use Cognito in client side code.", is it because of Amplify?

fzhangj2ee avatar Jun 12 '19 12:06 fzhangj2ee

@fzhangj2ee I was more referring to this particular project, see also Issue 149 ! The project really keeps up its promise of giving you a "quick start", but it seem to be no longer actively maintained and I was feeling exactly the same as @mordka when I tried to customize my fork and keep it up to date with recent angular versions. I'm not blaming the author as it probably was just meant to be sample app. Maybe @mordka can elaborate further on this as I just realized it’s the same person who commented on the current issue here, also note I have no prior experience with Amplify but it’s now on my list of things to evaluate :-)

tillkuhn avatar Jun 12 '19 14:06 tillkuhn

Update for those who try to evaluate Amplify Cognito within a fresh Angular Project: This nice tutorial should get you started quickly and shows you how to overcome some common pitfalls.

tillkuhn avatar Jun 13 '19 12:06 tillkuhn