Reputation: 47
How to enable Google Authentication in Angular 5 app?
I want to implement to enabled otp setup and when someone login to app whose otp is enabled than they input 6 digit code from Google Authenticator.
Upvotes: 1
Views: 3334
Reputation: 18473
For Angular 2+, there is a library that does just that: Speakeasy. Here's the workflow:
1 - Creation:
Now, both the user and the server share a secret that is used to generate time-based one-time passwords (TOTP).
2 - Authentication
Note there is no communication with Google Authenticator - don't bother looking for an API. Tokens are generated based on the time and the secret.
Upvotes: 1
Reputation: 34
As such there is no Google authentication directly provide in angular 5. Some how you have to write the API in other language like PHP or else which will contain your Google authentication code. And that API will return you the qrcode with the help of that you can simply integrate that along with UI in angular 5. Once user scan the qrcode , in next login just ask for 6 digit and give call to API by passing that 6 digit and get validate the same. I have implemented the same and it worked
Upvotes: 1
Reputation: 2255
There are many sample apps on GitHub and articles out there. - https://github.com/tjoudeh/AngularJSTwoFactorAuthentication - Use nodes plugin - https://www.npmjs.com/package/angular2-google-login
Upvotes: -1