supabase / supabase-flutter

Flutter integration for Supabase. This package makes it simple for developers to build secure and scalable products.
https://supabase.com/
MIT License
716 stars 168 forks source link

New Native login management crashes the app #693

Closed volkankoc closed 11 months ago

volkankoc commented 11 months ago

Describe the bug The newly announced google signin method directly crashes the application in the ios emulator. Auth transaction does not occur on Android

Expected behavior Waiting for the Auth transaction to occur

Screenshots

image

Version (please complete the following information): On Linux/macOS Please run dart pub deps | grep -E "supabase|gotrue|postgrest|storage_client|realtime_client|functions_client" in your project directory and paste the output here. supabase_flutter 1.10.24 │ ├── supabase 1.11.11 │ │ ├── functions_client 1.3.2 │ │ ├── gotrue 1.12.6 │ │ ├── postgrest 1.5.2 │ │ ├── realtime_client 1.4.0 │ │ ├── storage_client 1.5.4

dshukertjr commented 11 months ago

@volkankoc I experienced this when I skipped part 8 of the iOS setup instruction of the google_sign_in setup process to add CFBundleURLTypes in the Info.plist file. Could you double check if you have gone though the setup process properly for iOS? https://pub.dev/packages/google_sign_in#ios-integration__

volkankoc commented 11 months ago

@volkankoc I experienced this when I skipped part 8 of the iOS setup instruction of the google_sign_in setup process to add CFBundleURLTypes in the Info.plist file. Could you double check if you have gone though the setup process properly for iOS? https://pub.dev/packages/google_sign_in#ios-integration__

I did this. But the problem is still the same. IOS emulator App closes directly. There is no session on Android either.

Should we create a firebase app for the application and enable Google Auth permission?

What is this ? Where is the YOUR SERVER CLIENT ID?

image
dshukertjr commented 11 months ago

@volkankoc There are two ways to setup Google login. One that involves using Firebase, and one that does not. Either way should work, but step 7 is only required if you are setting it up using Firebase. I was able to sign in just fine without ever going to Firebase. If you are just directly setting up Google sign in, then you can skip step 3 - 7 as it says the following in the readme of google_sign_in package. You should actually be able to skip step 1 and 2 too.

As an alternative to adding GoogleService-Info.plist to your Xcode project, you can instead configure your app in Dart code. In this case, skip steps 3 to 7 and pass clientId and serverClientId to the GoogleSignIn constructor:

You might be making a mistake on step 8 where you enter the reverse DNS form of your iOS client ID. What is your iOS client ID and what does your CFBundleURLTypes section in your Info.plist file look like?

volkankoc commented 11 months ago

my info.plist file

<array>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <!-- TODO Replace this value: -->
                <!-- Copied from GoogleService-Info.plist key REVERSED_CLIENT_ID -->
                <string>com.googleusercontent.apps.123398018758-7n68sbf041gued3q2o28r850eoqrqfif</string>
            </array>
        </dict>
    </array>
    </dict>
</plist>
dshukertjr commented 11 months ago

@volkankoc Okay, that seems fine. I would also make sure that the bundle ID matches the one you used to register the iOS client ID.

Also, I just noticed that in your original screenshot you shared, I see some log messages about Firebase, but are you using Firebase or not in this project? Without Firebase, the step to enable native Google sign in should be the following:

  1. Create a GCP project
  2. Create iOS client ID
  3. Create web client ID
  4. Add CFBundleTypeRole to your Info.plist file
  5. Replace the web and iOS client ID variable on the sample code here

Try removing the supabase_flutter plugin and any Supabase related code you are using to isolate the issue.

If the app is crashing as soon as you call the _googleSignIn() method with Supabase code removed, then the issue lies on the google_sign_in plugin and not Supabase. If this is the case, then I would suggest you to open an issue with on the Flutter rpeo as the google_sign_in package is maintained by them.

dshukertjr commented 11 months ago

Also just a shot in the dark, but making sure you are using the latest Flutter version always helps. As well as running flutter clean

dshukertjr commented 11 months ago

Also, if you are using Firebase, you don't need the CFBundleTypeRole in your Info.plist file.

Either you are or you are not using Firebase, just be sure to follow the setup instructions on google_sign_in plugin carefully, and you should be able to perform Google sign in without an issue.

volkankoc commented 11 months ago

I did all the steps. Unfortunately it didn't happen again. iOS emulator crashes. I tried it on Android emulator and it didn't work either. User list appears on Android. But the auth process does not happen.

image

I debugged the codes. iOS crash occurs in this line.

GCP

image

Supabase google provider

image

We are using firebase in the project. But only remote config. The firebase packages I use are core and remote config.

Finally. Previous native login works. I'm having problems with the new build.

dshukertjr commented 11 months ago

@volkankoc If you are using Firebase for anything, you have to configure Google sign in through Firebase. It seems like you haven't followed the instruction on google_sign_in package properly in that case.

Here are things that I can find that you have mis-configured if you are using Firebase:

volkankoc commented 11 months ago

@volkankoc

  • You can find the web client ID from the GCP project associated to your Firebase project. You seem to be using a different project, which is probably what is causing the crash. After registering the app on Firebase, you should already see a web client ID generated by Firebase on your GCP project.

    
    I dont understand this

...... I will we create a flutter project in firebase? So when choosing a platform should I choose Android, iOS or Flutter?

dshukertjr commented 11 months ago

@volkankoc

You can find the web client ID from the GCP project associated to your Firebase project. You seem to be using a different project, which is probably what is causing the crash. After registering the app on Firebase, you should already see a web client ID generated by Firebase on your GCP project.

Every Firebase project has an GCP project associated to it. You need to find the GCP project associated to your Firebase project that you have connected to your Flutter app and copy and paste the web client ID of the GCP project into Supabase dashboard under auth -> providers -> Google -> Authorized Client IDs.

Sorry, but I can no longer assist you as you seem to have trouble setting up Google sign in on Flutter before even reaching Supabase.

I suggest you to read the instructions on google_sign_in and follow it carefully. Should you have any further questions regarding setting it up, open an issue on the Flutter repository. If you have any Supabase specific questions, feel free to open an issue at any time.

volkankoc commented 11 months ago

I solved my problem. I searched this gcp firebase project name. I used automatically generated keys. And the result is successful. Thanks a lot.