7

I want to read HealthDataTypes. Which Scope must I set when creating GoogleApiClient?

.addScope(new Scope(????))
Jim Simson
  • 2,774
  • 3
  • 22
  • 30
ViT-Vetal-
  • 2,431
  • 3
  • 19
  • 35
  • I'm on the same situation,.. just want to read.. did you find any way to do this? – Yotes Jan 02 '18 at 13:39
  • 1
    According to this (https://stackoverflow.com/questions/46066595/is-there-google-fit-rest-api-for-reading-blood-pressure-data) it works through the `HistoryApi` (at least via REST, but should be the same), I assume the scope will be the `FITNESS_BODY_READ_WRITE ` scope? EDIT: https://github.com/googlesamples/android-fit/issues/22 – damian Jan 02 '18 at 13:52
  • Yes, I found that and I also get a response from google with all the scopes: https://developers.google.com/identity/protocols/googlescopes#fitnessv1. I'll see if it works today – Yotes Jan 08 '18 at 14:03

3 Answers3

2

Google Fit provides fitness API scopes here. It is a list of specific scopes from which you can choose.

Rajeev Desai
  • 144
  • 2
  • 12
1

Based from this documentation, Google Fit restricts write access for the data types in HealthDataTypes to only certain developers because health data is potentially sensitive. Apps need user permission to read and write data of a restricted type. Any application can read fitness data of a restricted data type, but only Google-approved applications can write data of this type. If you would like to write to a restricted data type:

  1. Send an email to google-fit-restricted@google.com and request to be added to the whitelist of apps allowed to write data of a restricted type to Google Fit. Provide a brief description of the data types you would like access to.
  2. If the data from your application can originate from connected devices, please include the following details about your use case and connected devices:

    • Data Type(s) to be written to.
    • Device model.
    • Validation Protocols Met (e.g. ESH 2002, BHS, ISO15197:2013).
abielita
  • 13,147
  • 2
  • 17
  • 59
  • 1
    I want READ data. "Any application can read fitness data of a restricted data type" "Apps need user permission to read and write data of a restricted type." user permission - it is `Scope` – ViT-Vetal- Jun 16 '17 at 10:37
0

Ok, I found the correct answer by myself.. you can create a FittnessOption object using the required data types, and the get the implied scopes for it:

GFitUtils.buildFitnessOptions(
            readTypes,
            writeTypes
            ).getImpliedScopes();

(where readTypes and writeTypes are lists of DataTypes

in this way, you won't need to harcode the values from the google fit site

Yotes
  • 378
  • 3
  • 16