3

私は Google カレンダー API をいじっていて、何かに行き詰まっています。以下でこれを呼び出してカレンダーイベントを削除すると、最初のパスと通常は2番目のパスで正常に機能します。ただし、このメソッドを 2 回目または 3 回目に呼び出すと、(401) Unauthorized error が発生します。毎回同じ資格情報を使用します。例外が発生した場合は、キャッチで資格情報をリセットでき、正常に動作します。私はこれをする必要がないことを望みます。何か案は?

        CalendarService myService = new CalendarService("mycompany-myapp-1");
        myService.setUserCredentials("jo@username.com", "password");


        // set the query for the event
        EventQuery myQuery = new EventQuery(("http://www.google.com/calendar/feeds/jo@username.com/private/full"));
        myQuery.Query = "Cut the grass";
        myQuery.StartTime = DateTime.Now;
        myQuery.EndTime = DateTime.Now.AddDays(1);

        // find the event
        EventFeed myResultsFeed = null;

        try
        {
            // execute the query to find the event
            myResultsFeed = myService.Query(myQuery);                
        }
        catch (Exception ex)
        {
            // this is where i get the unauthorized exception
            // if i reset the credentials here it works fine

            myService.setUserCredentials("jo@username.com", "password"); 
            myResultsFeed = myService.Query(myQuery);
        }

        if (myResultsFeed != null && myResultsFeed.Entries.Count > 0)
        {
            AtomEntry firstMatchEntry = myResultsFeed.Entries[0];
            firstMatchEntry.Delete();
        }
4

3 に答える 3

0

もっと情報が必要だと思います。最良の方法は、fiddlerを使用することです。

于 2009-01-25T09:48:15.857 に答える
0

これを修正するには、ロード時に API に移動し、それをユーザーに表示しない Web ブラウザー コントロールを作成します。私が見つけた唯一の解決策は、問題を 100% 修正することです。

于 2012-04-05T19:17:31.623 に答える