Install react-google-login module
npm install react-google-login
step 2 :
Open Google developers console
Select you project -> Dashboard
select OAuth
in the left side menu
Creating OAuth Credentials:
1.
Add your add domain for react add (https://localhost:3000)
Now You can see the credentials in the dashboard
Setting Up in react
<GoogleLogin
clientId={props.authid} // provide your clint id here
onSuccess={responseGoogle}
render={(renderProps) => (
<button
onClick={renderProps.onClick}
disabled={renderProps.disabled}
class="bi bi-google btn btn-dark"
></button>
)}
theme="dark"
icon="false"
onFailure={responseGoogle}
/>
const responseGoogle = (e) => {
console.log(e.profileObj) //Data Of the User logged in
}
that's it you have successfully created an clint side google auth now you can use the data to store it into your backend and use it like normal JWT
authentication.
Discussion (0)