Google适合权限问题

时间:2018-12-04 17:11:47

标签: google-fit google-fit-sdk

我想获得有关Google Fit Rest Rest API的一些技术帮助。

我正在制作一个需要访问位置信息的应用,作为对我的请求的响应,我得到了这个json。

{
  "access_token": "ya29.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", 
  "scope": "https://www.googleapis.com/auth/fitness.activity.read https://www.googleapis.com/auth/fitness.location.write https://www.googleapis.com/auth/fitness.location.read https://www.googleapis.com/auth/fitness.body.read", 
  "token_type": "Bearer", 
  "expires_in": 3600, 
  "refresh_token": "1/XXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}

因此,我使用access_token发出了以下请求,它可以正常工作

https://www.googleapis.com/fitness/v1/users/me/dataset:aggregate

请求正文:

{
"startTimeMillis":1543682285000,
"endTimeMillis":1543941485000,
"aggregateBy: [
{ 
  "dataSourceId":"derived:com.google.calories.expended:com.google.android.gms:merge_calories_expended",
  "dataTypeName":"com.google.calories.expended"
}
],"bucketByTime":{"durationMillis":259200000}
}

我确实得到了正确的答案

但是在完成以下正文(更改了dataSourceId和dataTypeName)后

{
"startTimeMillis":1543682283000,
"endTimeMillis":1543941483000,
"aggregateBy":[
{
  "dataSourceId":"derived:com.google.location.sample:com.google.android.gms:merge_location_samples",
  "dataTypeName":"com.google.location.sample"}
],"bucketByTime":{"durationMillis":259200000}
}

我知道了

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "forbidden",
    "message": "No permission to read data for this private data source."
   }
  ],
  "code": 403,
  "message": "No permission to read data for this private data source."
 }
}

还尝试使用所有适用范围(读和写):

 "scope": "https://www.googleapis.com/auth/fitness.activity.write
           https://www.googleapis.com/auth/fitness.blood_pressure.read
           https://www.googleapis.com/auth/fitness.blood_pressure.write
           https://www.googleapis.com/auth/fitness.reproductive_health.write
           https://www.googleapis.com/auth/fitness.activity.read
           https://www.googleapis.com/auth/fitness.reproductive_health.read
           https://www.googleapis.com/auth/fitness.nutrition.write
           https://www.googleapis.com/auth/fitness.body_temperature.write
           https://www.googleapis.com/auth/fitness.body_temperature.read
           https://www.googleapis.com/auth/fitness.nutrition.read
           https://www.googleapis.com/auth/fitness.oxygen_saturation.write
           https://www.googleapis.com/auth/fitness.body.write
           https://www.googleapis.com/auth/fitness.body.read
           https://www.googleapis.com/auth/fitness.oxygen_saturation.read
           https://www.googleapis.com/auth/fitness.blood_glucose.write
           https://www.googleapis.com/auth/fitness.location.write
           https://www.googleapis.com/auth/fitness.location.read
           https://www.googleapis.com/auth/fitness.blood_glucose.read"

1 个答案:

答案 0 :(得分:0)

作为Google为改善数据隐私和安全性而不断努力的一部分,我们正在更新Google Fit API。在11月,我们对可通过Android版Fit API和Fit REST API读取位置样本的方式进行了更改。

展望未来,应用程序将只能读取他们已写入平台的位置样本。由于import feather df_hist=feather.read_dataframe('tmp/historical-raw') 流是由Fit平台在内部编写的,因此第三方开发人员将无法再访问它。

如果您的应用程序需要访问位置,我们建议您使用标准方法访问用户设备上的位置(请参见here)。