Google Sign-in with Nodejs Backend
Follow the instructions on Google official website
https://developers.google.com/identity/sign-in/web/backend-auth
Implementation
Send the ID token to your server
Make a post call with token on your angular app to Nodejs backend
import { HttpClient } from '@angular/common/http';
import {Injectable} from '@angular/core';
import { SocialUser } from 'angularx-social-login';
import {environment} from '../environments/environment';
const BACKEND_URL = environment.apiUrl;
@Injectable()
export class SigninService{
constructor(private httpClient: HttpClient){}
signin(usr: SocialUser){
let url = `${BACKEND_URL}/test`;
this.httpClient.post<{token: string}>(
url,
{
token: usr.idToken,
}
).subscribe((response) => {
console.log(response);
});
}
}Install Google-auth-library on your Nodejs app
Verify token with google auth lib
Verify sign-in status in the response
Last updated
Was this helpful?