/// <summary> /// if the service is using a Google Request Factory it will use that /// assuming credentials are set to retrieve the authentication token /// for those credentials /// /// Note that this only works for ClientLogin, not for any other type of authentication /// </summary> /// <returns>string</returns> public string QueryClientLoginToken() { if (this.Credentials != null) { GDataGAuthRequestFactory factory = this.factory as GDataGAuthRequestFactory; if (factory != null) { return(factory.QueryAuthToken(this.Credentials)); } } return(null); }
/// <summary> /// prepares the passed in service by setting the authentication credentials and the timeout settings /// </summary> /// <param name="s"></param> protected void PrepareService(Service s) { System.Net.ServicePointManager.Expect100Continue = false; if (settings.Credentials != null) { s.Credentials = settings.Credentials; } if (settings.AuthSubToken != null) { GAuthSubRequestFactory authFactory = new GAuthSubRequestFactory(s.ServiceIdentifier, settings.Application); authFactory.UserAgent = authFactory.UserAgent + "--IEnumerable"; authFactory.Token = settings.AuthSubToken; authFactory.PrivateKey = settings.PrivateKey; s.RequestFactory = authFactory; } else if (settings.ConsumerKey != null) { // let's create an OAuth factory GOAuthRequestFactory authFactory = new GOAuthRequestFactory(s.ServiceIdentifier, settings.Application); authFactory.ConsumerKey = settings.ConsumerKey; authFactory.ConsumerSecret = settings.ConsumerSecret; authFactory.Token = settings.Token; authFactory.TokenSecret = settings.TokenSecret; s.RequestFactory = authFactory; } else if (settings.OAuth2Parameters != null) { s.RequestFactory = new GOAuth2RequestFactory(s.ServiceIdentifier, settings.Application, settings.OAuth2Parameters); } else { GDataGAuthRequestFactory authFactory = s.RequestFactory as GDataGAuthRequestFactory; if (authFactory != null) { authFactory.UserAgent = authFactory.UserAgent + "--IEnumerable"; } } if (settings.Timeout != -1) { GDataRequestFactory f = s.RequestFactory as GDataRequestFactory; if (f != null) { f.Timeout = settings.Timeout; } } s.RequestFactory.UseSSL = settings.UseSSL; }
/// <summary> /// if the service is using a Google Request Factory it will set the passed /// in token to the factory. NET CF does not support authsubtokens here /// </summary> /// <returns>string</returns> public void SetAuthenticationToken(string token) { GDataGAuthRequestFactory factory = this.factory as GDataGAuthRequestFactory; if (factory != null) { factory.GAuthToken = token; } else { GAuthSubRequestFactory f = this.factory as GAuthSubRequestFactory; if (f != null) { f.Token = token; } } }
/// <summary>default constructor</summary> internal GDataGAuthRequest(GDataRequestType type, Uri uriTarget, GDataGAuthRequestFactory factory) : base(type, uriTarget, factory as GDataRequestFactory) { // need to remember the factory, so that we can pass the new authtoken back there if need be this.factory = factory; }