cuongdevjs / reactjs-social-login

Group Hook ReactJS components for login social network
https://react-social-login.netlify.app
MIT License
168 stars 75 forks source link

google login is not working. #137

Closed pankajVayuz closed 11 months ago

pankajVayuz commented 11 months ago

Describe the bug google social media log in not working .

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

cuongdevjs commented 11 months ago

please tell me further, your code or any screenshot

aniket0527 commented 11 months ago

@cuongdevjs I provide you screenshots why are you not resolving my issue?

drattansingh commented 11 months ago

I will like to add to this question since I'm also experiencing this issue. My Google login button was working perfect since April and suddenly stop working a few days ago for unknown reasons.

This is my code:

import {LoginSocialFacebook, LoginSocialGoogle } from 'reactjs-social-login'
import {FacebookLoginButton, GoogleLoginButton } from 'react-social-login-buttons'
.................

const handlerSocialMediaLogin=useCallback((data,provider)=>{        
    console.log(data) --> data retrieving for Facebook but not Google
    console.log(provider) --> prints out correct, either Facebook or Google
    .......
},[])

return(
............

<LoginSocialFacebook
    appId={process.env.REACT_APP_FACEBOOK_APP_ID}
    fieldsProfile={ "id,first_name,last_name,middle_name,name,name_format,picture,short_name,email" }
    onLoginStart={handlerFacebookLogin}
    onLogoutSuccess={handlerFacebookLogout}
    redirect_uri={null}
    onResolve={({provider,data})=>{ handlerSocialMediaLogin(data,provider) }}
    onReject={(err) => {
        console.log(err);
    }}
    // isOnlyGetToken
    >
    <FacebookLoginButton className={styles.socialBtns} />
</LoginSocialFacebook>

<LoginSocialGoogle
    client_id={process.env.REACT_APP_GOOGLE_APP_ID}
    onLoginStart={handlerFacebookLogin}
    redirect_uri={null}
    scope="openid profile email"
    discoveryDocs="claims_supported"
    access_type="offline"
    onResolve={({provider,data})=>{ handlerSocialMediaLogin(data,provider) }}
    onReject={err => {
        // console.log(err);
    }}
    >
    <GoogleLoginButton className={styles.socialBtns} />
</LoginSocialGoogle>

The login prompt is displaying correctly as follows: image

When I console.log(data) in handlerSocialMediaLogin method for Facebook I'm getting the user's email, full name and access token. However when I do the same with Google, I'm now getting the following:

image

It was working perfectly before (until a few days ago), I'd get the user's email, full name and access token however now I'm not getting these details and I have not changed anything in my code. Any help will be appreciated.

Version: "react-social-login-buttons": "^3.9.1", "reactjs-social-login": "^2.6.2",

Browsers: Chrome, Edge

Desktop: OS: Windows 10 Browser : Chrome Version : 117.0.5938.92 (Official Build) (64-bit) Browser : Edge Version : 117.0.2045.43 (Official build) (64-bit)

Smartphone: Device: One Plus 6 (A6000) OS: Android, Oxygen OS version, 11.1.2.2 Browser : Chrome Version : 117.0.5938.60

cuongdevjs commented 11 months ago

@drattansingh please try to upgrade to the newest version, 2.6.3

cuongdevjs commented 11 months ago

The old implementation is deprecated by Google, and the new mechanism GSI must be applied following Google's recommendation.

drattansingh commented 11 months ago

Is there any change in the code for the newest version? I updated to the newest version and my code follows online_demo but I'm still getting the same error when console.log(data): image

"react-social-login-buttons": "^3.9.1",
"reactjs-social-login": "^2.6.3",
drattansingh commented 11 months ago

I got it working. I updated to version 2.6.3 and modified my access_type like so:

access_type="online"

Thanks for your help