0

can anyone please let me know how this issue can be solved, is this scope issue or something else. URL : https://www.googleapis.com/fitness/v1/users/me/dataset:aggregate

  "error": {
    "status": "PERMISSION_DENIED", 
    "message": "No permission to read data for this private data source.", 
    "code": 403, 
    "errors": [
      {
        "reason": "forbidden", 
        "message": "No permission to read data for this private data source.", 
        "domain": "global"
      }
    ]
  }
}```
Merve Sahin
  • 1,008
  • 2
  • 14
  • 26
  • Does this answer your question? [Google fit permission problems](https://stackoverflow.com/questions/53618213/google-fit-permission-problems) – Andy Turner Sep 24 '20 at 15:11

1 Answers1

-1

You first need access to GPS, so you should add the permission to your manifest.xml file:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.fitness.sync">

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
....

And in your code you should pass the permissions to the sign-in account as follows:

public void signIn(){
    FitnessOptions fitnessOptions = FitnessOptions.builder()
            // add your read & write permissions here
            .addDataType(DataType.TYPE_LOCATION_SAMPLE, FitnessOptions.ACCESS_READ)
            .addDataType(DataType.TYPE_LOCATION_SAMPLE, FitnessOptions.ACCESS_WRITE)

            .addDataType(DataType.TYPE_LOCATION_TRACK, FitnessOptions.ACCESS_READ)
            .addDataType(DataType.TYPE_LOCATION_TRACK, FitnessOptions.ACCESS_WRITE)
             ...
            .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);
    }
}
Merve Sahin
  • 1,008
  • 2
  • 14
  • 26
  • I am trying this currently on oauth playground where all permissions are given as well as I have used the given scopes, still I am facing same error – Payal Pandey Sep 25 '20 at 08:54