Home > Software design >  AWS - React Native - Sign-up, Sign-in - Generating Session tokens in both client and server side
AWS - React Native - Sign-up, Sign-in - Generating Session tokens in both client and server side

Time:09-25

I am rather new to app development but I have the front end sign-up and sign-in form ready to go in react native. I want to send this data from the client to my AWS server to authenticate and create session tokens for each user. Online all I can find is using Cognito with Amplify. This is not a problem, although I want to be able to access the session token on both the client AND server side. Is this possible with Amplify?

I've used express as a react server on AWS in the past for Websockets, Routes and other fun stuff and was hoping to use that again since I am familiar with handling the backend logic that way. There, I'm assuming I would receive session tokens from clients and compare with what Cognito/Amplify has on record. If the session token matches, then dish out appropriate resources like an image, string, video etc. from other AWS services (e.g. S3, DynamoDB). Express would allow me to create custom API Routes/URLs in this way.

Does any of this sound like a good plan or even feasible? Are there other easier ways of achieving this? Its hard to sift through all the documentation they offer. Please let me know! Thanks in advance :)

CodePudding user response:

You can use Auth. currentAuthenticatedUser after the sign up process to get session auth token and save it in the front end. If you are going to send it to the backend you will need to make a PostConfirmation function in Cognito get the access token and send it to your backend.

The best way to do it its handle everything with Amplify, if you are more comfortable with Express I recommend you to create a Rest API in Amplify. They will handle everything related with the resources access.

I recommend you to watch this Youtube Channel. He has very neat tutorials. https://www.youtube.com/user/boyindasouth

  • Related