0

I have spent a few hours (if not days) reading and trying to get this thing working. I want to be able to authenticate users (and let them register) on my app. I've used, among other things, the Firebase console provided in Android Studio to set up the application (so it's registered and linked, and my google-services.json is indeed in the app folder).

The resources I've been following (they somehow ALL provide different code snippets, which is super confusing):

Screenshot of app's "Sign-in method" settings in the Firebase Console (so yes, I want to integrate those 3 options): Sign-in method in Firebase Console

My

Logcat when I test the "Google Sign In Button", after selecting my profile, in my one-and-only half-working Activity (the one that was mostly based off he "quickstart" ressource):

07-16 21:15:39.367 299-987/? E/FastThread: did not receive expected priority boost
07-16 21:15:40.350 842-1252/? E/WifiStateMachine: calculateWifiScore() report new score 56
07-16 21:15:42.892 842-1252/? E/WifiStateMachine: WifiStateMachine CMD_START_SCAN source -2 txSuccessRate=0.05 rxSuccessRate=0.06 targetRoamBSSID=any RSSI=-66
    startDelayedScan send -> 62 milli 20000
07-16 21:15:42.893 842-1252/? E/WifiStateMachine: WifiStateMachine CMD_START_SCAN with age=100016 interval=341718 maxinterval=300000
    WifiStateMachine CMD_START_SCAN full=false
07-16 21:15:43.370 299-987/? E/FastThread: did not receive expected priority boost
07-16 21:15:43.610 11462-11462/? W/AccountChipsFragment: Recording consent failed.
07-16 21:15:43.641 1701-1701/? W/ChimeraUtils: Non Chimera context
07-16 21:15:43.652 260-260/? W/SurfaceFlinger: couldn't log to binary event log: overflow.
07-16 21:15:43.745 1701-6139/? W/Auth: [GetToken] GetToken failed with status code: UNREGISTERED_ON_API_CONSOLE
07-16 21:15:43.746 9806-10025/? E/TokenRequestor: You have wrong OAuth2 related configurations, please check. Detailed error: UNREGISTERED_ON_API_CONSOLE
07-16 21:15:43.791 11462-11462/? W/AutoManageHelper: Unresolved error while connecting client. Stopping auto-manage.
07-16 21:15:43.862 8178-8178/com.example.payne.simpletestapp W/GoogleActivity: Google sign in failed
    com.google.android.gms.common.api.ApiException: 10: 
        at com.google.android.gms.common.internal.ApiExceptionUtil.fromStatus(Unknown Source)
        at com.google.android.gms.auth.api.signin.GoogleSignIn.getSignedInAccountFromIntent(Unknown Source)
        at com.example.payne.simpletestapp.Authentification.FirebaseActivity.onActivityResult(FirebaseActivity.java:102)
        at android.app.Activity.dispatchActivityResult(Activity.java:6218)
        at android.app.ActivityThread.deliverResults(ActivityThread.java:3655)
        at android.app.ActivityThread.handleSendResult(ActivityThread.java:3702)
        at android.app.ActivityThread.access$1300(ActivityThread.java:155)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1366)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:135)
        at android.app.ActivityThread.main(ActivityThread.java:5343)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
07-16 21:15:52.451 842-1252/? E/WifiStateMachine: calculateWifiScore() report new score 60
07-16 21:15:55.480 842-1252/? E/WifiStateMachine: calculateWifiScore() report new score 56

My build.gradle:

dependencies {
//...
    api 'com.google.firebase:firebase-auth:16.0.2'
    implementation 'com.firebaseui:firebase-ui-auth:4.1.0'
    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.google.android.gms:play-services-auth:15.0.1'
//...
}
apply plugin: 'com.google.gms.google-services'

Part of the other build.gradle:

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'
        classpath 'com.google.gms:google-services:4.0.1'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

NOTE: upgrading to classpath 'com.google.gms:google-services:4.0.2' gives me the following Logcat after pressing the "Google Sign In Button" and selecting my account:

07-16 21:26:09.488 13118-13118/com.example.payne.simpletestapp W/GoogleActivity: Google sign in failed
    com.google.android.gms.common.api.ApiException: 10: 
        at com.google.android.gms.common.internal.ApiExceptionUtil.fromStatus(Unknown Source)
        at com.google.android.gms.auth.api.signin.GoogleSignIn.getSignedInAccountFromIntent(Unknown Source)
        at com.example.payne.simpletestapp.Authentification.FirebaseActivity.onActivityResult(FirebaseActivity.java:102)
        at android.app.Activity.dispatchActivityResult(Activity.java:6218)
        at android.app.ActivityThread.deliverResults(ActivityThread.java:3655)
        at android.app.ActivityThread.handleSendResult(ActivityThread.java:3702)
        at android.app.ActivityThread.access$1300(ActivityThread.java:155)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1366)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:135)
        at android.app.ActivityThread.main(ActivityThread.java:5343)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)

This is kind of frustrating. I hope you guys can help. I can provide more code if needed... :/

I'm surprised there is no easy way to just copy-paste a bunch of code and get it running. Even setting up the Activity's UI is quite the process. I can't seem to find the specific pieces that I want from the, for example, "FirebaseUI-Android" repo.

payne
  • 4,691
  • 8
  • 37
  • 85

1 Answers1

0

I found some answer related to you problem. I'm not sure if it help, but I guess you might missing adding SHA-1 to your firebase console. Check this answer for more detail. Somebody already explained. Google sign in failed com.google.android.gms.common.api.ApiException: 10:

THANN Phearum
  • 1,969
  • 22
  • 19
  • This was not exactly the answer to all my problems, but somehow led me to find the right answers! Trying to connect my app to Firebase again (for the second time) through Android Studio regenerated a SHA1 key (or relinked it?). That was the first part of the fix. Secondly, the error talked about how I was lacking the activation of "Identity Toolkit API" and provided me with a link that brought me to the Google APIs website. Enabling this API solved the problem! Now I'm still stuck with an ugly looking UI and have only integrated Google out of the 3 desired methods, but that's a start!! Ty ! – payne Jul 17 '18 at 03:59
  • @payne Nice to hear that the problem is solved. Firebase should improve their docs and the code snippets. Sometime, I found a bit hard and confuse. The docs seem just for expert and experienced on it, but seem not quite work for novice. – THANN Phearum Jul 17 '18 at 08:55
  • Is there big difference between Google authentication and Username/Password ? It's the next one I want to integrate. – payne Jul 17 '18 at 15:43
  • Sorry, I haven't work on it much. But for Username/Password, you need to understand about rule configuration. – THANN Phearum Jul 17 '18 at 16:09
  • I've succeeded at integrating U/P properly (or at least, I believe so). Feel free to go help out with those [newer questions I've got](https://stackoverflow.com/questions/51413567/confusion-on-how-to-use-idtoken-properly). – payne Jul 19 '18 at 03:52