TobiasBuchholz / Plugin.Firebase

Wrapper around the native Android and iOS Firebase Xamarin SDKs
MIT License
211 stars 49 forks source link

Auth with Google resulting in FirebaseAuthException: 10 #108

Closed CasperStormHansen closed 1 year ago

CasperStormHansen commented 1 year ago

I have successfully used the library to login users with email and password in a MAUI app. I am trying to add the option to login with Google, but it only halfway works: the user is taken to the Google UI and can select their profile and enter their password. But on return to my app, an exception is thrown. The message is simply "Plugin.Firebase.Common.FirebaseAuthException: 10", and the "reason" property of the exception is "Undefined".

I get an "We noticed a new sign-in to your Google Account ..." email from Google, but I am not listed as one of the users in the list on Firebase.

I have followed the instructions here (except what only applies to iOS - I am only attempting on Android so far - or Facebook): https://github.com/TobiasBuchholz/Plugin.Firebase/blob/development/docs/auth.md. I have also enabled Google login on Firebase. In addition, I have created a keystore file, informed Firebase about the SHA1 code, and added the file to my project together with this information in the .csproj file:

<PropertyGroup>
    <AndroidSigningKeyStore>BarterApp.jks</AndroidSigningKeyStore>
    <AndroidSigningStorePass>[my password]</AndroidSigningStorePass>
    <AndroidSigningKeyAlias>BarterApp</AndroidSigningKeyAlias>
    <AndroidSigningKeyPass>[same password]</AndroidSigningKeyPass>
</PropertyGroup>

Finally, I have added the updated googleservice-info.plist and google-services.json files to my project.

Help would be much appreciated. Please let me know if any further information is needed. This is the first time I have opened a GitHub issue, so apologies if something is missing.

CasperStormHansen commented 1 year ago

I'm just gonna add a little more information in case it is helpful.

This is the error I get when I try to log in with Google:

Screenshot 01-09-2023 21 50 24

I have also tried to allow login with Facebook. That also leads to an error, and at an earlier stage:

Screenshot 01-09-2023 21 54 52

priyarishi commented 1 year ago

@CasperStormHansen - Getting the same issue. Any success ?

priyarishi commented 1 year ago

@CasperStormHansen I was able to resolve this by enabling the Google as a sign in /auth method in Firebase console. And then redownloading the google-services.json and GoogleService-Info.plist files.

Exact methods from the Firebase documentation

  1. Enable Google as a sign-in method in the Firebase console: In the Firebase console, open the Auth section.
  2. On the Sign in method tab, enable the Google sign-in method and click Save.

Verified on Android.

CasperStormHansen commented 1 year ago

@priyarishi I'm happy it works for you. But I had already done what you suggest. And redoing it by first disabling and the re-enabling Google and redownloading and adding the files made no difference for me.

CasperStormHansen commented 1 year ago

I managed to get Google login to work. It turns out I was using the wrong SHA1. May I suggest that information about how to get the right one is included in the documentation? This information is specific to Xamarin/MAUI, and therefore difficult to find in the general information about Firebase.

I am still struggling with Facebook login.

priyarishi commented 1 year ago

Open Command Prompt in the Project folder - And run the command keytool.exe -list -v -keystore "%LocalAppData%\Xamarin\Mono for Android\debug.keystore" -alias androiddebugkey -storepass android -keypass android

It will generate SHA1 fingerprint which I have used in development phase till now. I am only integrating the google login. So havent explored the facebook login till now.

priyarishi commented 1 year ago

@CasperStormHansen Encountering another issue. Where the plugin opens the google sso window for me , but I cant get back information about google login. How to implement the event or listen for response from google . Do you have any sample code to get info back when selecting facebook or google account.

CasperStormHansen commented 1 year ago

@priyarishi Information about the user is subsequently available through the properties of Plugin.Firebase.Auth.CrossFirebaseAuth.Current.CurrentUser.

Is that the information you were looking for? Due to my noobishness, I am not quite sure what you mean by "implement the event."

TobiasBuchholz commented 1 year ago

@priyarishi I've answered to your question at #113

@CasperStormHansen Thanks for the input, I've added the SHA-1 step to the auth docs. Btw this is an excellent first github issue 👍

priyarishi commented 1 year ago

@CasperStormHansen Sounds Great. Thanks for all the help. Appreciate your responses!

priyarishi commented 1 year ago

@CasperStormHansen Hey . Did you run this build on iphone device? Did it work for you. If see can you tell me the events in your AppDelegate.cs . And MauiProgram.cs for ios . Thanks in advance.

CasperStormHansen commented 1 year ago

@priyarishi No, I haven't gotten around to that yet.

I am more than happy to stay in contact with you, so we can help each other, but we probably shouldn't do it by developing this GitHub issue into an all-purpose discussion. Could you please contact me on casperstormhansen@gmail.com?