c# - 谷歌通讯录 API

标签 c# .net google-api google-oauth google-contacts-api

我刚开始使用 google contacts api,找不到如何使用身份验证内容的示例。

我使用了 Google Contacts API version 3.0了解联系人 API 基本工作流程的文档,但我不知道如何使用身份验证 token 。

在网上搜索后,我找到了教程 Google OAuth2 C#但在本教程中,他们使用的是 UserCredential 对象。在 Google Contacts API 3.0 版文档中,他们使用了 RequestSettings 对象。该对象有一个接受 ApplicationName 和 GDataCredentials 对象的构造函数。

所以我尝试了下面的代码:

GDataCrendentials credentials = new GDataCredentials(CLIENTID);
credentials.Username = "<my gmail username>";
this._requestSettings = new RequestSettings(GetApplicationName, _credentials);

我从发布的第二个链接获得的 ClientId。

所以我尝试使用代码访问我的联系人:

Feed<Google.Contacts.Contact> f = _contactsRequest.GetContacts();
IList<IContact> mappedContacts = new List<IContact>();

foreach (var contact in f.Entries)
{
    //do some stuff with it
}

使用这段代码,我在 foreach 处得到一个 Google.GData.Client.GDataRequestException:

{"Execution of request failed: https://www.google.com/m8/feeds/contacts/default/full"}

你能给我一个建议,这里有什么问题吗?

最佳答案

关于c# - 谷歌通讯录 API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26238329/

相关文章:

c# - Webdriver 在错误的输入元素中输入了错误的文本

c# - AddRange() 应该返回一个列表

c# - 覆盖 Form 的 OnFormClosing 以进行验证

google-analytics - 谷歌分析电子表格附加触发器

google-apps-script - 改为24小时。 DateRangeFilter 的模式

c# - ASP.NET Core ViewLocationExpander 在其他程序集中找不到 View

c# - 跨页面发布

.net - 无论如何可以轻松地在 Visual Studio 2010 中移动整个方法 block

c# - while on IDataReader.Read 不适用于产量返回,但 foreach on reader 可以

google-analytics - NativeApplicationClient.ClientIdentifier 未解析