public void OAuth2LeggedAuthenticatorTest() { Tracing.TraceMsg("Entering OAuth2LeggedAuthenticationTest"); OAuth2LeggedAuthenticator auth = new OAuth2LeggedAuthenticator( this.ApplicationName, this.oAuthConsumerKey, this.oAuthConsumerSecret, this.oAuthUser, this.oAuthDomain, this.oAuthSignatureMethod); HttpWebRequest request = auth.CreateHttpWebRequest("GET", new Uri("https://www.google.com/calendar/feeds/default/owncalendars/full")); HttpWebResponse response = request.GetResponse() as HttpWebResponse; if (response.StatusCode == HttpStatusCode.Redirect) { request = WebRequest.Create(response.Headers["Location"]) as HttpWebRequest; auth.ApplyAuthenticationToRequest(request); response = request.GetResponse() as HttpWebResponse; } Assert.IsTrue(response.StatusCode == HttpStatusCode.OK); }
protected override void ProcessRecord() { var _domain = dgcGoogleCalendarService.GetDomain(service.CalendarService); var _calendar = new CalendarEntry(); _calendar.Title.Text = calendarName; if (description != null) { _calendar.Summary.Text = description; } if (timeZone != null) { _calendar.TimeZone = timeZone; } try { if (service.Oauth == null) { throw new Exception("User -ConsumerKey/-ConsumerSecret in New-GdataService"); } if (service.OauthCalendarService == null) { throw new Exception("User -ConsumerKey/-ConsumerSecret in New-GdataService"); } var _postUri = new Uri("http://www.google.com/calendar/feeds/default/owncalendars/full"); var _oAuth2LeggedAuthenticator = new OAuth2LeggedAuthenticator("GDataCmdLet", service.Oauth.ConsumerKey, service.Oauth.ConsumerSecret, id, _domain); var _oAuthUri = _oAuth2LeggedAuthenticator.ApplyAuthenticationToUri(_postUri); var _createdCalendar = (CalendarEntry)service.OauthCalendarService.Insert(_oAuthUri, _calendar); var _calendarEntry = dgcGoogleCalendarService.CreateCalendarEntry(_createdCalendar); WriteObject(_calendarEntry); } catch (Exception _exception) { WriteObject(_exception); } }