Google Apps - 远程服务器返回错误:(401)未经授权

时间:2013-12-04 07:18:24

标签: c# asp.net google-calendar-api google-drive-api google-apps

我正在尝试从gdrive(谷歌文档)获取文件,但它返回错误远程服务器返回错误:(401)未经授权。同样的错误也返回谷歌日历。我尝试了DotNetOpenAuth和Oauth来授权用户。

错误(来自Google日历):

执行请求失败:https://www.google.com/calendar/feeds/default/private/full?max-results=1&xoauth_requestor_id=mymail%40gmail.com&start-min=2013-12-04T12:37:34%2B05:30&sortorder=ascending&singleevents=true

我做错了什么?

感谢。

我的代码(谷歌日历):

        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);
        }

0 个答案:

没有答案