Google Contacts API和范围?

时间:2013-06-28 12:52:14

标签: google-contacts

目前我正在尝试检索所有用户的联系信息以及检索其唯一的用户ID。

我们的应用需要使用用户谷歌联系人,用户将使用谷歌登录。因此,我们需要一些方法来识别每个唯一身份用户(很可能是谷歌提供的唯一用户ID)

这是否只能使用google contacts API。

我为检索访问令牌而进行的初始调用是:

https://accounts.google.com/o/oauth2/auth?client_id=51672309258-94cnvnrkrverd72neakom9d3siscda5o.apps.googleusercontent.com&redirect_uri=http://localhost/lunch/oauth.php&scope=https://www.google.com/m8/feeds/&response_type=code

但是,我不相信此次调用返回的访问令牌具有任何用户ID信息,并且也不提供从Google+ Api检索用户ID的权限。

有没有人可以从谷歌联系人API获取唯一的用户ID?有一些获取用户联系人的用户ID但我需要获取实际用户ID(即我获得其联系人的用户)的例子?

这是否需要另一个范围,还是可以通过使用联系人API来完成?

2 个答案:

答案 0 :(得分:0)

您可以通过他/她的电子邮件地址识别用户,这是唯一的AFAIK。当您向google contacts api发出请求时,您会在xml中获得一个名为Id的字段,即用户的电子邮件地址。

例如,你可以要求所有的联系人,你会得到一个像this这样的xml .Id字段是你想要的,根据你使用的编程语言,lib等,你可以得到它您现有的权限。例如在C#和gdata中你会做这样的事情(googleCredentials应该是你的对象):

        var cr = new ContactsRequest(settings);
        var feed = cr.GetGroups();
        googleCredentials.Email = feed.AtomFeed.Id.Uri.Content;

答案 1 :(得分:0)

Note: The special userEmail value default can be used to refer to the authenticated user.

from the documentation documentation. You may try the keyword default as userEmail.