3

I'm developing with google fit api on Android. I setup my project followed the guide from google doc. But when I test auth on real device, it will show a white page with the loading sign after I select my google account like the image. It just loading forever and without any error.

Here is what I did in my project:

// AndroidManife
// because target API level 28
<uses-permission android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION" />
// google-services.json
"oauth_client": [
        {
          "client_id": "xxx-xxx.apps.googleusercontent.com",
          "client_type": 1,
          "android_info": {
            "package_name": "xxx.xxx.xxx",
            "certificate_hash": "xxxxhash"
          }
        },
        {
          "client_id": "xxx-xxx.apps.googleusercontent.com",
          "client_type": 3
        }
      ]
// my auth activity, sample code from google doc
FitnessOptions fitnessOptions = FitnessOptions.builder()
      .addDataType(DataType.TYPE_STEP_COUNT_DELTA, FitnessOptions.ACCESS_READ)
      .addDataType(DataType.AGGREGATE_STEP_COUNT_DELTA, FitnessOptions.ACCESS_READ)
      .build();

    GoogleSignInAccount account = GoogleSignIn.getAccountForExtension(this, fitnessOptions);

    if (!GoogleSignIn.hasPermissions(account, fitnessOptions)) {
      GoogleSignIn.requestPermissions(
        this, // your activity
        GOOGLE_FIT_PERMISSIONS_REQUEST_CODE, // e.g. 1
        account,
        fitnessOptions);
    }

OAuth 2.0 client ID is ok in Google API Console. I check the keystore SHA-1 is correct.

I also put my keystore SHA-1 in Firebase project settings.

Google sign in is opened in Firebase Authentication -> Sign-in Method.

What's I missed? What should I do? Please help me. Thanks very much.

Shuai
  • 41
  • 3

3 Answers3

2

if Your app is marked as "EXTERNAL" on "OAuth consent screen" - you need to add tester Users

enter image description here

A Y M A N
  • 31
  • 4
  • This worked.!! https://support.google.com/accounts/thread/4692671/stuck-loading-when-signing-into-apps-with-jy-google-account?hl=en Check out this link too.. – Jerin Sep 27 '21 at 03:10
1

I figure it out. It because I didn't edit my app name in Google API Console -> OAuth consent screen.

Shuai
  • 41
  • 3
  • There are multiple reasons but mainly its related to specific scope. In my case the user I was selecting was not added as test user for my oauth consent screen. – imLolman Feb 18 '21 at 19:20
0

For me, the problem was my project was marked as external in the oAuth Consent screen. In that case, you have to add a test user to continue using your google fit APIs in the application.

Minkesh Jain
  • 1,140
  • 1
  • 10
  • 24