google api error - not able to get the google sign in to work

Viewed 552

I have an app that needs to access Google Fit Api.
I can get the google sign-in pop up. But the next screen, requesting permission for my data types (TYPE_STEP_COUNT_DELTA, AGGREGATE_STEP_COUNT_DELTA) is not displayed.

As soon as I choose my google account the pop-up goes away and nothing is displayed further.

enter image description here

I have followed all the steps for the Setup mentioned here https://developers.google.com/fit/android/get-started

  1. Set up my project in Google API developer console

  2. Install google play services packages in my android studio

  3. Created an OAuth 2.0 Client ID enter image description here

  4. Add the dependencies

  dependencies {
        implementation 'com.google.android.gms:play-services-fitness:20.0.0'
        implementation 'com.google.android.gms:play-services-auth:19.0.0'
    }
  1. Enable sign-in options "google" in my firebase console

Yet I do not get the further screens.

My code is as below:

 public void setFitnessOption() {
        fitnessOptions =
                FitnessOptions.builder()
                        .addDataType(DataType.TYPE_STEP_COUNT_DELTA, FitnessOptions.ACCESS_READ)
                        .addDataType(DataType.AGGREGATE_STEP_COUNT_DELTA, FitnessOptions.ACCESS_READ)
                        .build();
      }

public void checkFitInstalled() {
        if (isGoogleFitPermissionGranted()) {
            GetData();  //step count query       
        } else {
          requestGoogleFitPermission();
            GetData();    //step count query
        }
      }

public boolean isGoogleFitPermissionGranted() {
        if (GoogleSignIn.hasPermissions(GoogleSignIn.getLastSignedInAccount(this), fitnessOptions)) {
          return true;
        } else {
          return false;
        }
      }

public void requestGoogleFitPermission() {
        GoogleSignInAccount account = GoogleSignIn.getAccountForExtension(this, fitnessOptions);
        GoogleSignIn.requestPermissions(
                this,
                GOOGLE_FIT_PERMISSIONS_REQUEST_CODE,
                account,
                fitnessOptions);
      }


What am I missing out?? struggling for days with this issue. Any input would be great!!!

1 Answers
  1. Go to Google Cloud Platform.
  2. In the left panel of your project, select OAuth Consent Screen.
  3. Scroll down and you'll see Test Users. Here, add the email address of the user. Hope it works for you.
Related