Monday, 24 April 2017

How to do authentication in an Ionic 2 app through a AWS Cognito/Twitter Digits/NodeJS combination

I'm building an app using Ionic 2 (based on Angular 2), that I would like to use phone number authentication for.

After a bit of research I think that Twitter/Fabric Digits would definitely be the best solution because, well, it's free.

There are a few complications though - let me explain my process:

1) Ionic handles the front end of things (obviously).

2) The Ionic app connects to a Node Express based REST API that is currently sitting on an AWS Elastic Beanstalk instance.

3) I would like to use Digits to authenticate my user and have Cognito give users access based on that authentication. (Access to their info only, of course).

My problem though is that I can't use Digits directly on the app because there's no proper Ionic 2 support for it.

What I have been able to do though, is create an API endpoint where the client app would send a phone number, receive a token, then send out the code (the user recevied via SMS)+token back to Node. At which point node communicates again with Digits to verify the code, which returns simply "Success" or failure with a reason.

Getting to my question, assuming a successful response from Digits, what do I do next? i.e. how can I connect my Digits authenticated user with Cognito and get authentication properly working? What should I send back to the client side once authenticated so I can then authenticate with Cognito?

Please keep in mind that I'm an absolute beginner when it comes to AWS services and backends in general, so if I'm doing something blatantly wrong, please feel free to roast. :)

I don't know if code would be super beneficial for anything here but if someone needs some examples of how I implement stuff please let me know and I'd be happy to post some.

Thanks for your time!



via Mo Tawakol

No comments:

Post a Comment