Comments (1)
Found the problem, it was as the stacktrace was saying. I can't define login as I did in the example above having it outside the scope of GoogleOAuthProvider
.
const login = useGoogleLogin({
onSuccess: (tokenResponse) => console.log(tokenResponse),
});
I resolved this by explicitly following the example and creating a custom component for useGoogleLogin
.
import React from "react";
import { GoogleOAuthProvider, GoogleLogin, useGoogleLogin, TokenResponse, CodeResponse } from "@react-oauth/google";
import GoogleLoginButton from "./GoogleLoginButton";
const CLIENT_ID = process.env.REACT_APP_GOOGLE_OAUTH_CLIENT_ID || "";
interface props {
setAccessToken: React.Dispatch<React.SetStateAction<string>>;
}
const Authorize: React.FC<props> = ({ setAccessToken }) => {
return (
<div id="authorizeButton">
<GoogleOAuthProvider clientId={CLIENT_ID}>
<GoogleLoginButton />
</GoogleOAuthProvider>
</div>
);
};
export default Authorize;
import React from "react";
import { useGoogleLogin } from "@react-oauth/google";
const GoogleLoginButton: React.FC = () => {
const login = useGoogleLogin({
onSuccess: (tokenResponse) => console.log(tokenResponse),
});
return (
<div>
<button onClick={() => login()}>Login with google✌</button>
</div>
);
};
export default GoogleLoginButton;
from react-oauth.
Related Issues (20)
- Request for GoogleOAuthProvider to work as a local component wrapper HOT 2
- How to use API client to make authorized requests using the access token?
- Redirect URI for vercel preview links HOT 1
- In useGoogleOneTapLogin, google one tap is still popping up after user logs in dispite disabled prop HOT 1
- Using `useGoogleLogin` on page init doesn't sign in HOT 2
- Adopting FedCM regarding Chrome blocking third party cookies in future. Seeing warnings: Chrome will block third party cookies HOT 6
- Granting permission every time I use the same Google account to sign in HOT 4
- How to use GoogleLogin with fedcm
- How to store jwt token? HOT 1
- doubled <span>Continue with Google</span>
- about nonOAuthError HOT 1
- About useLogin
- Error 400: redirect_uri_mismatch HOT 1
- onSuccess is not being called when I try to login with useGoogleLogin HOT 1
- Profile picture of the first account used to sign in, does not change when signing with another account
- How can i get the user details from this code
- prompt: 'none' not working for useGoogleLogin
- Credentials JWT, auth flow for useGoogleLogin hook
- use_fedcm_for_prompt on implicit flow with useGoogleLogin
- GoogleLogin button is not responsive
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-oauth.