如何获取Google Fit API的userId?

问题描述

如何获取用于从Google Fit API获取用户活动数据的userId。 GET https://www.googleapis.com/fitness/v1/users/userId/dataSources/dataSourceId 我可以通过替换userId来获取数据,但我想为其他用户创建一个应用程序。

解决方法

As stated in the documentation,用户ID唯一受支持的值为“ me”。

“我”所指的用户身份由您随请求传递的OAuth令牌传达。

如果您要访问用户的数据,则他们需要向您授予OAuth令牌。