Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
February 16, 2022 11:26 am GMT

React Js google auth

Install react-google-login module
npm install react-google-login

step 2 :
Open Google developers console

Create new project
Image description

Enter The Project Name
Image description

Select you project -> Dashboard

select OAuth in the left side menu
Image description

Creating OAuth Credentials:
1.
Image description

  1. Enter Project name and select you gmail id

    Image description

  2. Add your add domain for react add (https://localhost:3000)
    Image description

Now You can see the credentials in the dashboard
Image description

Setting Up in react
<GoogleLogin
clientId={props.authid}
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
}

Image description


Original Link: https://dev.to/abipravi/react-js-google-auth-50de

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To