如何获取个人资料信息 google 照片库 api
How to get profile info google photo library api
我正在编写一个简单的逻辑来使用 Google 照片 REST API 列出图片。我想在他们登录到我的应用程序后打印连接的用户个人资料。 但是我无法在 REST API 中找到任何端点来获取 Gmail 或 Drive REST 中的用户配置文件 APIs。
https://developers.google.com/photos/library/guides/get-started#request-id
同时,我尝试从 oAuth2 访问令牌获取用户详细信息,但它没有提供任何用户详细信息,如邮件 ID 或名称。
GET https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=ACCESS_TOKEN
响应:
{
"issued_to": "xxxxx.apps.googleusercontent.com",
"audience": "xxxxxx.apps.googleusercontent.com",
"scope": "https://www.googleapis.com/auth/photoslibrary",
"expires_in": 3522,
"access_type": "offline"
}
有没有办法从上面的 oAuth2 access_token(独立于范围)检索用户配置文件?
恐怕目前这是不可能的。 oAuth2 令牌不包含用户的电子邮件。通过 Google API 获取用户电子邮件的唯一方法是允许 https://www.googleapis.com/auth/userinfo.email
范围,并使用 oAuth2 API 或人员 API .您可以使用的调用可能是以下任何一种:
GET https://www.googleapis.com/oauth2/v2/userinfo
GET https://www.googleapis.com/userinfo/v2/me
GET https://www.googleapis.com/plus/v1/people/me
我正在编写一个简单的逻辑来使用 Google 照片 REST API 列出图片。我想在他们登录到我的应用程序后打印连接的用户个人资料。 但是我无法在 REST API 中找到任何端点来获取 Gmail 或 Drive REST 中的用户配置文件 APIs。
https://developers.google.com/photos/library/guides/get-started#request-id
同时,我尝试从 oAuth2 访问令牌获取用户详细信息,但它没有提供任何用户详细信息,如邮件 ID 或名称。
GET https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=ACCESS_TOKEN
响应:
{
"issued_to": "xxxxx.apps.googleusercontent.com",
"audience": "xxxxxx.apps.googleusercontent.com",
"scope": "https://www.googleapis.com/auth/photoslibrary",
"expires_in": 3522,
"access_type": "offline"
}
有没有办法从上面的 oAuth2 access_token(独立于范围)检索用户配置文件?
恐怕目前这是不可能的。 oAuth2 令牌不包含用户的电子邮件。通过 Google API 获取用户电子邮件的唯一方法是允许 https://www.googleapis.com/auth/userinfo.email
范围,并使用 oAuth2 API 或人员 API .您可以使用的调用可能是以下任何一种:
GET https://www.googleapis.com/oauth2/v2/userinfo
GET https://www.googleapis.com/userinfo/v2/me
GET https://www.googleapis.com/plus/v1/people/me