Reputation: 23322
I am building an app using Angular and NodeJS.
I've heard about AWS Cognito and would like to use it in my app. However it is very unclear in the documentation how it is supposed to work.
There is an example on how to use Cognito with an Angular SPA, but there is no word on how I can use it to authenticate users on my backened NodeJS server.
How is NodeJS supposed to know if a user is logged in? I can think of several possible answers, but none appear in the documentation and there is surprisingly no code sample. So I decided to ask here before investing a lot of time in trial and error.
Upvotes: 2
Views: 1252
Reputation: 19748
You can use AWS Cognito Userpools in your backend NodeJS server to authenticate users. The steps are as follows.
Note: Since the id_token is a standard JavaScript Web Token (JWT) you can find a library to validate it. Refer AWS documentation Using Tokens with User Pools for more details.
Upvotes: 4