reactjs-social-login icon indicating copy to clipboard operation
reactjs-social-login copied to clipboard

Unable to get the code for server

Open sarankup opened this issue 3 years ago • 5 comments

Describe the bug I want to get the user code from my reactjs application. I will then pass the code to my server-side to get the auth-token along with refresh token. UUnfortunately, I am getting profile info and access token only. I could not get the code.

To Reproduce Steps to reproduce the behavior:

<LoginSocialGoogle
            isOnlyGetCode={true}
            client_id={socialAuthProps.google.key}
            onLoginStart={onLoginStart}
            onResolve={({ provider, data }) => {
              setProvider(provider)
              setProfile(data)
            }}
            onReject={(err) => {
              console.log(err)
            }}
          >
            <GoogleLoginButton />
          </LoginSocialGoogle>```

**Expected behavior**
code in the response

**Desktop (please complete the following information):**
 - OS: Macintosh
 - Browser Chrome 
 - Version 106

sarankup avatar Oct 08 '22 11:10 sarankup

Hi. What is the user code you are mentioning?

cuongdevjs avatar Oct 14 '22 15:10 cuongdevjs

Hi, As per the OAuth specification, we can pass &response_type=code params. So, once the user is authenticated, we will get a code in response to our redirect URL. This code will be passed to our server-side (back-end) to authenticate from our application backend session.

Using the code, we will get the refresh-token to renew the user session with oauth provider to get a new auth key.

Also, isOnlyGetCode={true} there is no difference regardless of true or false in this config.

sarankup avatar Oct 17 '22 02:10 sarankup

As far as I know, the new mechanism doesn't get code on response. You can try downgrading to version 2.7.1.

cuongdevjs avatar Oct 17 '22 02:10 cuongdevjs

By looking at the code (https://www.npmjs.com/package/reactjs-social-login), i see the latest version is 2.5.6. I am not sure what you mean by 2.7.1

sarankup avatar Oct 20 '22 04:10 sarankup

oh, sorry about that. I mean version 2.0.1

cuongdevjs avatar Oct 20 '22 07:10 cuongdevjs