【问题标题】:Google Contacts API谷歌通讯录 API
【发布时间】:2014-12-02 00:24:46
【问题描述】:

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

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

在网上搜索后,我找到了教程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:

{“请求执行失败:https://www.google.com/m8/feeds/contacts/default/full”}

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

【问题讨论】:

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


【解决方案1】:
猜你喜欢
  • 2015-05-31
  • 1970-01-01
  • 2012-11-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-11-30
  • 2011-09-02
相关资源
最近更新 更多