Why isn't the google accounts login page showing up even though I have implemented the expo auth session library with react native?

Viewed 11

I have been following the tinder 2.0 react native tutorial https://youtu.be/qJaFIGjyRms At 1:04:00 he sets the sign in method to: "await Google.logInAsync()" but I have noticed the google app auth library used in the video is now deprecated, I am redirected to use expo auth session instead, with this new library I cannot tell whether the google sign in is working or not as I am simply redirected back to the homepage after clicking the login button.

Here is my code with response printed in the console:

Screenshot: screenshot

code:

    import React, { createContext, useContext } from 'react'
    import * as WebBrowser from "expo-web-browser";
    import { Button } from "react-native";
    import * as Google from "expo-auth-session/providers/google";
    import { useEffect, useState } from "react";
    import { useNavigation } from "@react-navigation/native";
    import { GoogleAuthProvider, signInWithCredential } from 'firebase/auth';

    const AuthContext = createContext({});

    const user = null

    WebBrowser.maybeCompleteAuthSession();

    const GoogleLogin = () => {
      const navigation = useNavigation();
      const [request, response, promptAsync] = Google.useAuthRequest({
        expoClientId:
          "236293699216-bst43767un873mcddmmrpgf4v2h088jd.apps.googleusercontent.com",
        iosClientId:
          "236293699216-6jdpm0rd6kn5d0qlbh1vgva5afgbqgib.apps.googleusercontent.com",
          webClientId:
            "236293699216-9a0nknjdq7ie79h40iubg0tddokgogfv.apps.googleusercontent.com",
          scopes: ["profile", "email"],
           permissions: ["public_profile","email", "gender", "location"],
         });



        const asyncAuthRequest = async () => {
        if (response?.type === "success") {
          const { authentication } = response;
          // await AsyncStorage.setItem("accessTocken", "hihi");

          //navigation.navigate"Home");

          const { idToken, accessToken} = response;
          const credential = GoogleAuthProvider.credential(idToken, accessToken);
          await signInWithCredential(auth, credential)
        }
          return Promise.reject();

      };

      useEffect(() => {
        asyncAuthRequest();
      }, [response]);

      console.log('response', response)

      return (
        <Button
          disabled={!request}
          title="Login"
          onPress={() => {
            promptAsync();
          }}
        />


      );
    };

    export default GoogleLogin;
0 Answers
Related