Google Sign-in with Angular Front End
Here is Google sign-in official website:
https://developers.google.com/identity/sign-in/web/sign-in
However, I found Angular Social Login library will be easier to use:
https://www.npmjs.com/package/angularx-social-login
Implementation
Get credentials on Google developers console
Go to this url https://console.developers.google.com/apis/credentials and login with your google account.
Create a new project if you don't have one.
You need to register OAuth consent form screen
Under App information section, put your apps basic info.
Under App domain section, put http://localhost:4200/ as your application home domain.
Under Authorized domains, leave it as blank
On Scopes tab, choose the information you request users to authorize for your app.
On Test users tab, you can only test with test user for 100 times if you have sensitive scope logins, and put your testing google account here.
On summary tab, you can review the information.
Once you have the OAuth consent form, you can create Credentials now
Select OAuth clientID
Select Web application as Application type
Under Authorized JavaScript origins, put http://localhost:4200/
Under Authorized redirect URIs, put http://localhost:4200/
Once completed, it will pop up Your Client ID and Your Client Secret which will be used in your angular app.
Angular Social Login library
It's simple to follow the steps on the official web site.
https://www.npmjs.com/package/angularx-social-login
Settings in app.module.ts file
Add SocialLoginModule
Add your app client ID in the providers
Add a login button at your html
At your type script file, call google api with angularx-social-login
Check your browser console to see if you get the response from Google.
Ref
https://codinglatte.com/posts/angular/sign-in-with-google-angular/
https://levelup.gitconnected.com/sign-in-with-google-oauth-in-angular-8-e716ed7f3b2f
Client Id
https://stackoverflow.com/questions/22266729/google-oauth-keeping-the-client-id-secret
Last updated