google-login-react-uet
v1.0.7
Published
Made by ha
Downloads
9
Readme
google-login-react-uet
Simple package react login with google
Install
npm install --save google-login-react-uet
or
yarn add google-login-react-uet
Usage
import React from 'react'
import GoogleLoginButton from 'google-login-react-uet'
import 'google-login-react/dist/index.css'
const Example = () => {
const handleGoogleSuccess = (googleUser: any) => {
const profile = googleUser.getBasicProfile();
console.log("ID: " + profile.getId()); // Don't send this directly to your server!
console.log('Full Name: ' + profile.getName());
console.log('Given Name: ' + profile.getGivenName());
console.log('Family Name: ' + profile.getFamilyName());
console.log("Image URL: " + profile.getImageUrl());
console.log("Email: " + profile.getEmail());
// The ID token you need to pass to your backend:
const id_token = googleUser.getAuthResponse().id_token;
console.log("ID Token: " + id_token);
}
const handleGoogleError = (error: any) => {
console.log(error);
}
return <GoogleLoginButton
clientId={'YOUR_CLIENTID.apps.googleusercontent.com'}
onSuccess={handleGoogleSuccess}
onFailure={handleGoogleError}/>
/>
}