我正在尝试从gdrive(谷歌文档)获取文件,但它返回错误远程服务器返回错误:(401)未经授权。同样的错误也返回谷歌日历。我尝试了DotNetOpenAuth和Oauth来授权用户。
错误(来自Google日历):
我做错了什么?
感谢。
我的代码(谷歌日历):
GOAuthRequestFactory requestFactory = new GOAuthRequestFactory("writely", "AppName");
requestFactory.ConsumerKey = "key";
requestFactory.ConsumerSecret = "secret";
String user = "mail@domain.com";
DocumentsService client = new DocumentsService("AppName");
client.RequestFactory = requestFactory;
// Retrieve user's list of Google Docs
DocumentsListQuery query = new DocumentsListQuery();
query.Uri = new OAuthUri("https://docs.google.com/feeds/default/private/full", user, requestFactory.ConsumerKey);
DocumentsFeed feed = client.Query(query);
foreach(DocumentEntry entry in feed.Entries)
{
Console.WriteLine(entry.Title.Text);
}