我想在服务器上使用googlefitrestapi并对Fit数据执行CRUD操作。用户已通过身份验证,https://www.googleapis.com/auth/fitness.activity.write,https://www.googleapis.com/auth/fitness.body.read,https://www.googleapis.com/auth/fitness.body.write的权限已被授予应用程序的fit数据。用户通过身份验证后,服务器将接收UID和OAUTH_令牌。在
UID = "XYZ"
OAUTH_TOKEN="FOO_BAR"
APP_SECRET_KEY = "XXX"
CLIENT_ID = "AAA"
但每当我在restapi上获取/发布时,它就会抛出401错误。在
^{pr2}$输出
401
{
"error": {
"errors": [
{
"domain": "global",
"reason": "authError",
"message": "Invalid Credentials",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Invalid Credentials"
}
}
这应该列出https://developers.google.com/fit/rest/v1/get-started中提到的所有可用数据源。在
这里怎么了?在
花了许多小时之后,问题的解决办法如下。在
UserId应该是
me
,access_token应该是最新的,因为access token将在60分钟内过期。在相关问题 更多 >
编程相关推荐