Hello all!
I hope this is the correct forum to ask.
I was able to set with success the auth with email/password. But I was not hable to make it work with Google sing/in.
my credential page able to configure the authorised JavaScript Origins & authorised redirect URL. but I still getting "
Error 400: redirect_uri_mismatch Request details: flowName=GeneralOAuthFlow
This is my code(with modify creditials)
import { useEffect, useState } from 'react';
import * as WebBrowser from 'expo-web-browser';
import * as Google from 'expo-auth-session/providers/google';
import AsyncStorage from '@react-native-async-storage/async-storage';
import * as AuthSession from 'expo-auth-session';
WebBrowser.maybeCompleteAuthSession();
const useGoogleSignIn = () => {
const [request, response, promptAsync] = Google.useAuthRequest({
androidClientId: "123456789012-abcdefghijklmno1234567890123456.apps.googleusercontent.com",
iosClientId: "123456789012-pqrstuvwxyzabcdefghijklmno123456.apps.googleusercontent.com",
webClientId: "123456789012-abcdefghijklmnopqrstuvwx1234567890.apps.googleusercontent.com",
redirectUri: "https://yourappname.firebaseapp.com/__auth/handler", // Explicitly set to your Firebase hosting URL
});
const [userInfo, setUserInfo] = useState(null);
useEffect(() => {
if (response?.type === "success") {
getUserInfo(response.authentication.accessToken);
}
}, [response]);
const getUserInfo = async (token) => {
if (!token) return;
try {
const response = await fetch("https://www.googleapis.com/userinfo/v2/me", {
headers: {
Accept: 'application/json',
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json'
},
});
const user = await response.json();
await AsyncStorage.setItem("@user", JSON.stringify(user));
setUserInfo(user);
} catch (e) {
console.log(e);
}
};
return { promptAsync, userInfo };
};
export default useGoogleSignIn;
Thank you in advance !!!
"