amazon-archives / aws-sdk-react-native

AWS SDK for React Native (developer preview)
Apache License 2.0
631 stars 68 forks source link

Basic authentication example? #47

Closed hszeto closed 6 years ago

hszeto commented 7 years ago

Coming from Firebase Auth, the AWS Cognito seems quite overwhelming. Does anyone have a good example/tutorial/doc that they can share for just a basic user signup and login with Cognito in React Native. (Not oauth-ing with facebook) Thanks.

npalethorpe commented 7 years ago

Hi, I'm unsure as to whether this will be of any help to you but if you're looking to do user pool login/sign up within React Native using Cognito you can use the amazon-cognito-identity-js JS library which can be found at https://github.com/aws/amazon-cognito-identity-js

Primarily you'll be interested in looking at Use Case 4 within the documentation: https://github.com/aws/amazon-cognito-identity-js#usage

If you're wondering on how to integrate it with React Native, I've literally just finished getting a working model built up (after much hair pulling) - I've written a basic guide of the bits I could remember which can be found here: https://github.com/aws/amazon-cognito-identity-js/issues/327

I'm not going to say its a perfect integration and it requires modifying the cognito library but it appears to work from what I can see so far...still early days - I'm just waiting to run into my next bug!

Hope that helps

hszeto commented 7 years ago

Thanks @npalethorpe ! Could you fix the link? they redirect me to a 404 page.

npalethorpe commented 7 years ago

@hszeto sorry about that - links are updated! :)

namankumar commented 7 years ago

@npalethorpe, that's great effort, thanks! Question - since this is based on the Cognito JS, it has no native components does it? All authentication tasks happen on the single JS thread?

npalethorpe commented 7 years ago

@namankumar thanks :) - it has no native components; just javascript. I have replaced the localStorage methods (Which wouldn't work in React Native) with AsyncStorage, which as it sounds; is Asynchronous - but its still single threaded.

jmparsons commented 7 years ago

@hszeto Just published this: https://github.com/AirLabsTeam/react-native-aws-cognito-js/. It's based off Amazon Cognito Identity SDK for JavaScript using the new React Native branch of the AWS SDK for JavaScript.

MatheusParanhos commented 6 years ago

They also released aws-mobile-react-native-starter which will give you a example of what you want... does anybody know how to integrate with facebook login tho?

undefobj commented 6 years ago

Please also take a look at the new library which we released to address these scenarios: https://github.com/aws/aws-amplify