【问题标题】:Getting user profile name and image in Google Calendar API在 Google Calendar API 中获取用户个人资料名称和图像
【发布时间】:2019-02-27 09:24:30
【问题描述】:

我正在开发一个网络应用程序,该应用程序可以修改用户的 Google 日历活动并可以显示他们的用户个人资料名称和图像(头像)。经过一番研究,我发现:

https://developers.google.com/calendar/ Google Calendar API,非常直观,但没有提及获取用户的个人资料信息。

https://developers.google.com/identity/sign-in/web/Google 登录 API,非常直观,但登录机制似乎与日历 API 完全不同。

我应该选择哪一个?谢谢。

【问题讨论】:

  • @MaximillianLaumeister 这看起来不错,但为了使用它,我需要 Calendar API 才能给我用户的电子邮件地址,但它不能。

标签: javascript google-api google-calendar-api google-signin


【解决方案1】:

如果你看一下日历的快速入门https://developers.google.com/calendar/quickstart/js

gapi.auth2.getAuthInstance()

它返回gapi.auth2.GoogleAuth 其中有currentUser.get()。所以你可以

var profile = gapi.auth2.getAuthInstance().currentUser.get()

获取profile

然后profile.getBasicProfile()获取姓名、头像等。

希望对你有帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-08-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-06-24
    • 1970-01-01
    相关资源
    最近更新 更多