2014-10-07 95 views
2

我刚开始使用google contacts api,并且找不到如何使用验证内容的示例。Google Contacts 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“}

您能否给我一个建议这里有什么问题?

+0

https://developers.google .com/api-client-library/dotnet/guide/aaa_oauth – heavyd 2014-10-07 14:35:50

+0

我也检查了这一点,但问题是我需要联系API的GDataCrendentials对象而不是UserCredentials对象。 – WhiteIntel 2014-10-07 14:47:22

回答

相关问题