新的Google DocumentsList API .NET客户端?
问题描述:
有没有人用过google-gdata的“新DocumentsList API”?新的Google DocumentsList API .NET客户端?
我想检索一个文件列表,我遇到了验证问题。
使用Google.GData.Documents类工作正常,但是当我尝试以类似的方式使用,然后更新Google.GData.Docs我得到一个401
如果有帮助,我已经注意到,我的电子邮件地址不会附加到网址中,就像我使用Google.GData.Documents时一样。
任何人都可以帮忙吗?
感谢
代码的要求:
[Authorize]
public void ListAsync()
{
string requestorId = "";
if (Session["email"] != null)
{
// get a documents list for the user that logged in
requestorId = Session["email"].ToString();
}
// create an OAuth factory to use
GOAuthRequestFactory requestFactory = new GOAuthRequestFactory("writely", APPLICATION_NAME);
requestFactory.ConsumerKey = "XXX";
requestFactory.ConsumerSecret = "YYY";
DocsService service = new DocsService(APPLICATION_NAME);
// this way does work
//service.setUserCredentials("username", "password");
// this way doesn't work
service.RequestFactory = requestFactory;
Uri queryUri = new Uri("https://docs.google.com/feeds/default/private/full");
service.AsyncOperationCompleted += DocsQueryCompleted;
AsyncManager.OutstandingOperations.Increment();
service.QueryFeedAync(queryUri, DateTime.MinValue, this);
}
答
的Google.GData.Docs库是一个实验,实际上已经退役,而Google.GData.Documents最近已经更新来实现文档列表API的版本3的所有部分。
检查所有新样本代码的新文档一起在https://developers.google.com/google-apps/documents-list/
答
OAuth2Parameters parameters = new OAuth2Parameters();
parameters.ClientId = CLIENT_ID;
parameters.ClientSecret = CLIENT_SECRET;
parameters.RedirectUri = REDIRECT_URI;
parameters.Scope = SCOPE;
string authorizationUrl = OAuthUtil.CreateOAuth2AuthorizationUrl(parameters);
试图获得与authorizationUrl身份验证令牌。将其粘贴到网络浏览器中。然后... 使用令牌作为strToken那样。您现在拥有所有的信息。
OAuth2Parameters parameters = new OAuth2Parameters();
parameters.ClientId = CLIENT_ID;
parameters.ClientSecret = CLIENT_SECRET;
parameters.RedirectUri = REDIRECT_URI;
parameters.Scope = SCOPE;
parameters.AccessToken= accessToken;
parameters.RefreshToken= refreshToken;
GOAuth2RequestFactory requestFactory = new GOAuth2RequestFactory(null, "MyDocumentsListIntegration-v1", parameters);
Serv = new DocumentsService("MyDocumentsListIntegration-v1");
Serv.RequestFactory = requestFactory;
此代码必须工作。
发布您的代码。删除所有私人信息并在其位置使用示例值。一旦你有问题的代码,我会扭转我的downvote。 – 2012-01-31 13:14:15