使用Google Api PHP客户端库获取电子邮件地址

时间:2021-04-06 21:53:49

I am trying to use the Google API PHP Client library for Google Calendar v3.

我正在尝试将Google API PHP客户端库用于Google Calendar v3。

My website prompts user to do OAuth authentification. And retrieves calendar list, adds/deletes events. What I don't know is that would that be possible to get google-account(email such as *****@gmail.com) that user uses for OAuth via the PHP library. I would want this information so that the program can run some code only for specifiec accounts only.

我的网站提示用户进行OAuth身份验证。并检索日历列表,添加/删除事件。我不知道的是,通过PHP库可以获得用户用于OAuth的google-account(电子邮件,如*****@gmail.com)。我想要这些信息,以便程序只能为特定的帐户运行一些代码。

I digged into the code a little, but wasn't successful.

我稍微深入了解代码,但没有成功。

Please somebody help me.

请有人帮帮我

1 个解决方案

#1


Getting the authenticated users email address is a little tricky. First off you will have to add another scope probably email

获取经过身份验证的用户电子邮件地址有点棘手。首先,您必须添加另一个范围,可能是电子邮件

https://developers.google.com/+/api/oauth

Then you use the Google+ API to get the person people.get this should return the email for you.

然后,您使用Google+ API来吸引用户。我们应该为您返回电子邮件。

#1


Getting the authenticated users email address is a little tricky. First off you will have to add another scope probably email

获取经过身份验证的用户电子邮件地址有点棘手。首先,您必须添加另一个范围,可能是电子邮件

https://developers.google.com/+/api/oauth

Then you use the Google+ API to get the person people.get this should return the email for you.

然后,您使用Google+ API来吸引用户。我们应该为您返回电子邮件。