google-signin: Android: Error: Login action cancelled after first sign-in
When creating a new user using the Google platform identity (https://admin.google.com), the first time I sign in to the app in android(for iOS works fine), I get Error: Login action cancelled. When creating a new user in the normal interface, the user sounds like this.
When you sign-in again, the problem is also not observed.
This is an example using what I am trying to do. Google wing in will be used to enter firebase, but the error falls before it reaches the firebase function.
import React from 'react';
import type {Node} from 'react';
import {
Button,
SafeAreaView,
} from "react-native";
import auth from '@react-native-firebase/auth';
import { GoogleSignin } from '@react-native-google-signin/google-signin';
const App: () => Node = () => {
async function onGoogleButtonPress() {
// Get the users ID token
const { idToken } = await GoogleSignin.signIn();
// Create a Google credential with the token
const googleCredential = auth.GoogleAuthProvider.credential(idToken);
// Sign-in the user with the credential
await auth().signInWithCredential(googleCredential);
const token = await auth().currentUser?.getIdToken();
console.log("### token", token);
}
return (
<SafeAreaView>
<Button
title="Google Sign-In"
onPress={() => onGoogleButtonPress().then(() => console.log('Signed in with Google!'))}
/>
<Button
title="Google Sign-Out"
onPress={async () => {
await auth().signOut();
await GoogleSignin.signOut();
}}
/>
</SafeAreaView>
);
};
export default App;
Expected results
Error: Login action cancelled
Actual Behavior
Success sign-in
Environment
- react-native version “0.69.3”
- @react-native-google-signin/google-signin version “8.0.0”
- Pixel 2 API 30 , Android 11
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 23
same problem as me. I took a log and the id token returned as null and an error popped up