Google oauth not redirecting

Everything worked ok before. I had an issue working with google auth on iOS in previous thread. Now I’m back on web and notice when I click my sign in with google button nothing seems to happen. Before it would redirect to
https://accounts.google.com/o/oauth2/auth?response_type=code
https://accounts.google.com/o/oauth2/auth?response_type=code
. Now it does nothing. I tried logging g for errors but no error Relevant code useGoogleSignIn.ts
export const useGoogleSignIn = () => {
const { data: isAuthenticated } = authClient.useSession();
const navContainerRef = useNavigationContainerRef();

useEffect(() => {
if (isAuthenticated) {
if (navContainerRef.isReady()) {
router.push('/recent-businesses');
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isAuthenticated, navContainerRef.isReady()]);

return useCallback(async () => {
console.log('callback called');
try {
const { error, data } = await authClient.signIn.social({
provider: 'google',
callbackURL: '/',
});
if (error) {
console.error(error);
}

console.log(data);
} catch (err) {
console.error(err);
}
}, []);
};
export const useGoogleSignIn = () => {
const { data: isAuthenticated } = authClient.useSession();
const navContainerRef = useNavigationContainerRef();

useEffect(() => {
if (isAuthenticated) {
if (navContainerRef.isReady()) {
router.push('/recent-businesses');
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isAuthenticated, navContainerRef.isReady()]);

return useCallback(async () => {
console.log('callback called');
try {
const { error, data } = await authClient.signIn.social({
provider: 'google',
callbackURL: '/',
});
if (error) {
console.error(error);
}

console.log(data);
} catch (err) {
console.error(err);
}
}, []);
};
Sign-in.tsx
const googleSignIn = useGoogleSignIn();
const googleSignIn = useGoogleSignIn();
<Pressable
style={[styles.altLoginButton]}
onPress={async () => {
console.log('pressed');
googleSignIn();
}}
>
<Image
source={
Platform.OS !== 'web'
? 'google'
: require('@/assets/images/google.png')
}
style={styles.googleIcon}
/>
<Text style={[styles.altLoginText, Fonts.interRegular]}>
Google
</Text>
</Pressable>
<Pressable
style={[styles.altLoginButton]}
onPress={async () => {
console.log('pressed');
googleSignIn();
}}
>
<Image
source={
Platform.OS !== 'web'
? 'google'
: require('@/assets/images/google.png')
}
style={styles.googleIcon}
/>
<Text style={[styles.altLoginText, Fonts.interRegular]}>
Google
</Text>
</Pressable>
Package version
"better-auth": "1.2.6-beta.6",
"better-auth": "1.2.6-beta.6",
Video of log would be attached
Solution:
have you enable disableDefaultFetchPlugins when you init the auth client?
Jump to solution
3 Replies
ak11
ak11OP2w ago
@bekacru
Solution
bekacru
bekacru2w ago
have you enable disableDefaultFetchPlugins when you init the auth client?
ak11
ak11OP2w ago
oh yes. it should be false?

Did you find this page helpful?