Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android: Error: Login action cancelled after first sign-in #1088

Closed
KMarkovskiy opened this issue Aug 3, 2022 · 23 comments
Closed

Android: Error: Login action cancelled after first sign-in #1088

KMarkovskiy opened this issue Aug 3, 2022 · 23 comments

Comments

@KMarkovskiy
Copy link

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
@seora
Copy link

seora commented Dec 14, 2022

same problem as me. I took a log and the id token returned as null and an error popped up

@BrodaNoel
Copy link

Same problem here (I guess).
90% of the users that are opening the app in Android, and open get Sign in action cancelled.

This is my code, am I missing something?

import { GoogleSignin } from '@react-native-google-signin/google-signin';

// ...

try {
  GoogleSignin.configure();

  await GoogleSignin.hasPlayServices();
  const { user } = await GoogleSignin.signIn();

} catch (error) {
  actions.errors.track(error);
}

@BrodaNoel
Copy link

I just checked Sentry and seems like this issue is happening right after upgrading to Expo SDK 47

@BrodaNoel
Copy link

I just realized I forgot to add @react-native-google-signin/google-signin in the plugins in app.json file.
Will create a new build right now and see what happens tomorrow after some users try the app

@BrodaNoel
Copy link

@KMarkovskiy @seora could you also check if you forget that line and see if that fixes the error

@EasonHeee
Copy link

Hey @BrodaNoel thanks for reporting. I am seeing the same issue, is there a way to solve the cancelled login issue?

@vioku
Copy link

vioku commented Feb 24, 2024

same problem

@andrisole92

This comment was marked as abuse.

@andrisole92

This comment was marked as abuse.

@andrisole92

This comment was marked as abuse.

@andrisole92

This comment was marked as abuse.

@vonovak
Copy link
Collaborator

vonovak commented Mar 17, 2024

@andrisole92 thanks for your comment; However your issue appears to be different from the original one.
For me, there isn't really anything to look at - there's no runnable reproduction of the issue.

If the issue is critical to you and you need extra help, you can hire me - contact information is in my profile.
Thank you 🙂

edit: I have hidden the user's comments because he has made repeated false claims for which he provided no proof for. Instead of engaging in a productive discussion and providing a reproducible example to provided basis for his accusations, he depicted the package in bad light.
This issue tracker welcomes bug reports that follow the issue template and provide information for everyone to verify. It's not a place for baseless false claims.

@andrisole92

This comment was marked as abuse.

@BrodaNoel
Copy link

Hey @vonovak ,

Could you please add something like Don't use in production on Android for Expo projects - the package is broken

It makes me feel outrageous that I have to pay for a third-party Google Sign-in plugin while the official open-source version is broken.

This is not an official library. This is not inside Google account.

@vonovak
Copy link
Collaborator

vonovak commented Mar 18, 2024

Hi @andrisole92 ,
You have not yet presented a proof that the problem you're seeing is due to this library, and I therefore don't see a reason to declare that it's broken.

Secondly, as was already correctly noted, there's no "official" Google sign in open source package for react native or for Android, for that matter.

As for your feeling, I'm sorry that you feel that way but allow me to explain - the reason why the "premium" package exists is to fund the maintenance of the resources in this organization. That includes both the private and public repositories, documentation and even contributions outside of this organization (AppAuth for iOS, Google Sign In SDK for iOS). I have spent a lot of my free time on making these, and sponsors make the efforts sustainable.

Lastly, you don't "have to" pay for anything, and if you have a problem, you're in a great position to fix it.

Thank you 🙂

@andrisole92

This comment was marked as abuse.

@andrisole92

This comment was marked as abuse.

@vonovak
Copy link
Collaborator

vonovak commented Mar 20, 2024

hello again,

I feel like I got free ice cream that was poisoned

I'm sorry you feel that way. It seems what you're saying is that I either introduced a major bug, or knowingly keep one in the OSS code - and I want to deny that. There are differences in functionality between the "original google sign in" module for sponsors and the free one but they are very minor.

What you're getting for sponsoring is new architecture support and one tap sign in, which is a very different implementation from the "original sign in".

I am also saddened that you don't trust my word that the package is broken in prod.

I trust your word that you're running into an issue. Do I trust that it's because of this package? Well, I'd be repeating myself here so I'll refer to my above comment(s).

Here's a video of the OSS Google sign in, in an app that's built with release build config, on a physical device. I recorded it now.

SVID_20240320_092959_1.mp4

Please don't invite me to your testing groups and etc. If I am to do anything about your issue, I need https://stackoverflow.com/help/minimal-reproducible-example

There's nothing more to add from my side, thank you for your comments. :)

@TheoOliveira
Copy link

I just realized I forgot to add @react-native-google-signin/google-signin in the plugins in app.json file. Will create a new build right now and see what happens tomorrow after some users try the app

Did added the plugin to the app.json worked for you?

@BrodaNoel
Copy link

I just realized I forgot to add @react-native-google-signin/google-signin in the plugins in app.json file. Will create a new build right now and see what happens tomorrow after some users try the app

Did added the plugin to the app.json worked for you?

It fixed some of the issues I had. Yes. You always have to add the plugin if it's there. It's a required thing

@TheoOliveira
Copy link

TheoOliveira commented Apr 26, 2024

In my case It was something i wasn't aware. I did everything according to the docs. I am using expo and since i am using default credentials from expo and i already have google play console connected I had to add the upload credential from play store as well to firebase sha1. Hope this helps someone.

@dragonmaster784
Copy link

@vonovak you really have nothing to be sorry about bro.
Some people (@andrisole92 👀) are just not nice and unhelpful.

Anyways, if anyone is still getting this type "cancelled" returning on sign in:
One such scenario will require you to make sure you check that App Check is not being enabled before. If you enable App Check or it is not configure the right way, your sign in can be cancelled. This is especially something to watch out for with Internal App Shared builds, or Simulators when you don't have debug tokens and all that.

      // comment out this if you are making 
      // await GoogleSignin.enableAppCheck({
      //  debugProviderAPIKey,
      // }) */

      const hasPlayServices = await GoogleSignin.hasPlayServices({ showPlayServicesUpdateDialog: true })
      if (!hasPlayServices) {
        throw new Error("auth/play-services-unavailable")
      }

      if (GoogleSignin.hasPreviousSignIn()) {
        await GoogleSignin.signOut()
      }

      const signInResult = await GoogleSignin.signIn()

      if (signInResult.type === "cancelled") {
        throw new Error("auth/sign-in-cancelled")
      }

@vonovak
Copy link
Collaborator

vonovak commented Feb 15, 2025

Hello 👋 ,
it seems there's not much to be added to this issue.

With that, I'm closing it,
Thank you! 🙂

@vonovak vonovak closed this as completed Feb 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants