Google 适配权限问题
Google fit permission problems
我想获得一些关于 google 适合休息 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"
作为 Google 改善数据隐私和安全的持续努力的一部分,我们正在更新 Google Fit API。 2018 年 11 月,我们通过 Fit API for Android 和 Fit REST API.
更改了位置样本的读取方式
今后,应用程序将只能读取它们已写入平台的位置样本。由于merge_location_samples
流是由健身平台内部编写的,第三方开发者无法再访问。
如果您的应用程序需要访问位置信息,我们建议您使用标准方法访问用户设备上的位置信息(请参阅 here)。
我想获得一些关于 google 适合休息 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"
作为 Google 改善数据隐私和安全的持续努力的一部分,我们正在更新 Google Fit API。 2018 年 11 月,我们通过 Fit API for Android 和 Fit REST API.
更改了位置样本的读取方式今后,应用程序将只能读取它们已写入平台的位置样本。由于merge_location_samples
流是由健身平台内部编写的,第三方开发者无法再访问。
如果您的应用程序需要访问位置信息,我们建议您使用标准方法访问用户设备上的位置信息(请参阅 here)。