MomenSherif / react-oauth

Google OAuth2 using the new Google Identity Services SDK for React 🚀
https://www.npmjs.com/package/@react-oauth/google
MIT License
1.07k stars 134 forks source link

Credentials JWT, auth flow for useGoogleLogin hook #348

Open oobohP opened 4 months ago

oobohP commented 4 months ago

Do you think it would be possible to add a optional refs to your GoogleLogin component which flow gives the JWT token

allowing very similar behavior, we can hide the button that is iframed by google, put our own custom button on top and use that when the user clicks our div/button it will give the illusion that our button is the Login with google

this would reduce the overhead needed to call additional apis or exchange auth code's with google on the backend

it would look something like this

    <div>
      <div style={{ display: "none" }}>
        <GoogleLogin
          ref={googleLoginBtnRef}
          onSuccess={credentialResponse => {
            console.log(credentialResponse);
            // Handle authentication success
          }}
          onError={() => {
            console.log("Login Failed");
            // Handle login error
          }}
        />
      </div>

      <StyledNormalButton
        onClick={onCustomButtonClick} // Trigger Google login when your custom button is clicked
        role='link'
        label={label}
        variant='rounded-outlined'
        type='button'
        leftIcon={
          <Image
            width={32}
            height={32}
            src={`${basePath}/assets/images/google-login.svg`}
            alt={label}
          />
        }
      />
    </div>
deepakbytebard commented 1 month ago

most awaited component prop