0

HELP!!!

Now, I did Made Login Screen, I will provide a Code but in that code I can not login with google using firebase

Error: \[ERROR: DEVELOPER_ERROR\]

now how to solve this error?

Now, I am able to displays the Google Sign in Button!

I want to add Login Screen in My app.

LOGIN SCREEN:


import { View, Text, Button } from 'react-native';
import React, { useEffect, useState } from 'react';
import { requestUserPermission } from './src/utils/notificationHeloper';
import { GoogleSignin, GoogleSigninButton, statusCodes } from '@react-native-google-signin/google-signin';

const App = () => {
  const [userInfo, setUserInfo] = useState(null);
  console.log('user ni information - ', userInfo)

  useEffect(() => {
    // Request user permissions for notifications
    requestUserPermission();

    // Configure Google Sign-In
    GoogleSignin.configure({
      scopes: ['https://www.googleapis.com/auth/drive.readonly'],
      webClientId: '592869271313-lo5bpc98nlkpv15rcrpde3f2f9nr9nh0.apps.googleusercontent.com',
      offlineAccess: true,
    });
  }, []);

  const signIn = async () => {
    try {
      await GoogleSignin.hasPlayServices();
      const userInfo = await GoogleSignin.signIn();
      setUserInfo(userInfo);
    } catch (error) {
      if (error.code === statusCodes.SIGN_IN_CANCELLED) {
        console.log('User canceled Google sign-in');
      } else if (error.code === statusCodes.IN_PROGRESS) {
        console.log('Google sign-in is already in progress');
      } else if (error.code === statusCodes.PLAY_SERVICES_NOT_AVAILABLE) {
        console.log('Play services are not available');
      } else {
        console.log('Error during Google sign-in', error);
      }
    }
  };

  return (
    <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
      <Text>App</Text>
      {!userInfo ? (
        <GoogleSigninButton
          style={{ width: 192, height: 48 }}
          size={GoogleSigninButton.Size.Wide}
          color={GoogleSigninButton.Color.Dark}
          onPress={signIn}
        />
      ) : (
        <View>
          <Text>Welcome, {userInfo.user.name}!</Text>
          <Text>Email: {userInfo.user.email}</Text>
          <Button title="Sign Out" onPress={signOut} />
        </View>
      )}
    </View>
  );
};

export default App;

Error during Google sign-in [Error: DEVELOPER_ERROR]
toyota Supra
  • 3,181
  • 4
  • 15
  • 19
Gohel Meet
  • 23
  • 4

1 Answers1

0

Refer the following blog which is the exact explanation step by step and been used and verified by me:- https://abhishek-garg.medium.com/google-sign-in-react-native-6afb7c1a8368

Aman Khan
  • 34
  • 2