1
GoogleカレンダーAPI V3を使用してカレンダーを更新しようとしています。私はC#のコードからカレンダーのイベントを取得したいと思います。私はGoogleカレンダーAPI V3用の.Netライブラリを使用しています。GoogleカレンダーAPI V3
何らかの理由でリクエストを承認できません。私は利用可能なコードサンプルに従おうとしましたが、無駄でした。ダイレクトメッセージまたは
を送信中プロトコル例外エラーが発生しました:
if (arg.RefreshToken(state))
が実行されたとき、私はこの例外を受け取るprivate void GetEvents() { var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description,MyClientId, MySecurityId); var auth = new OAuth2Authenticator<NativeApplicationClient>(provider, GetAuthorization); CalendarService myService = new CalendarService(auth); try { Events result = myService.Events.List(MyCalendarId).Fetch(); if (result.Items.Count > 0) { } } catch (Google.GoogleApiRequestException ex) { //throw ex; } } private static IAuthorizationState GetAuthorization(NativeApplicationClient arg) { IAuthorizationState state = new AuthorizationState(new[] { "https://www.googleapis.com/auth/calendar.readonly" }); state.Callback = new Uri(NativeApplicationClient.OutOfBandCallbackUrl); if (!string.IsNullOrEmpty(refreshToken)) // refreshToken you stored in step 4 { try { state.RefreshToken = refreshToken; if (arg.RefreshToken(state)) // This is calling out to the OAuth servers with the refresh token getting back a session token, returns true if successful. { if (state.RefreshToken != refreshToken) // if the refresh token has changed, save it. { //PersistRefreshToken(authorization.RefreshToken); } return state; // Retain the authorization state, this is what will authenticate your calls. } } catch (ProtocolException ex) { throw ex; } } return state; }
:次は私が私の要求を許可するために使用している私のコードスニペットです
応答を得ています。
お願いします!
ここにこの投稿を見て、それがあなたを助けるかどうかを見てください。 http://stackoverflow.com/questions/8899000/c-sharp-google-calendar-v3-2-legged-authentication-fails – HK1