Reputation: 121
I am trying to do a react-natvie-app with google-service, this is my code:
useAuth.js
import * as Google from "expo-google-app-auth";
const AuthContext=createContext({});
const config={
androidClientId:"551241887947-trikk6eg7jvilk8cjrpp1maq10cb11gr.apps.googleusercontent.com",
scopes:["profile","email"],
permissions:["public_profile","email","gender","location"],
}
export const AuthProvider = ({children}) => {
const signInWithGoogle = async () =>{
Google.logInAsync(config).then(async (logInResult) =>{
if(logInResult.type === "success"){
//login..
}
}).catch((error)=>{
console.log("Api call error");
alert(error.message);
})
}
return (
<AuthContext.Provider value={{
user:null,
signInWithGoogle,
}}
>
{children}
</AuthContext.Provider>
);
};
export default function useAuth(){
return useContext(AuthContext);
}
here is my
LoginScreen.js
import React from 'react';
import useAuth from '../hooks/useAuth';
const LoginScreen = () => {
const {signInWithGoogle}=useAuth();
return (
<View>
<Text>login to the app</Text>
<Button title="login" onPress={signInWithGoogle}/>
</View>
);
};
export default LoginScreen;
when I press the button I get this exception
I am using a firestore. in my firebase project I add the two fingerprint SHA-1 and SHA-256 I googled it and I didn’t found any solution for this problem. thanks for the assitance!
Upvotes: 1
Views: 195
Reputation: 121
I found a solution for this problem,In order to resolve you need to work with real android phone,and that's because the emulator is reason behind it.and it didn't work properly.
Upvotes: 2