public OAuth2Template(string clientId, string clientSecret, string authorizeUrl, string authenticateUrl, string accessTokenUrl, bool useParametersForClientAuthentication) { ArgumentUtils.AssertNotNull(clientId, "clientId"); ArgumentUtils.AssertNotNull(clientSecret, "clientSecret"); ArgumentUtils.AssertNotNull(authorizeUrl, "authorizeUrl"); ArgumentUtils.AssertNotNull(accessTokenUrl, "accessTokenUrl"); this.clientId = clientId; this.clientSecret = clientSecret; string str = "?client_id=" + HttpUtils.UrlEncode(clientId); this.authorizeUrl = authorizeUrl + str; if (authenticateUrl != null) { this.authenticateUrl = authenticateUrl + str; } else { this.authenticateUrl = null; } this.accessTokenUrl = accessTokenUrl; this.restTemplate = this.CreateRestTemplate(); this.useParametersForClientAuthentication = useParametersForClientAuthentication; if (!this.useParametersForClientAuthentication) { this.restTemplate.RequestInterceptors.Add(new BasicSigningRequestInterceptor(clientId, clientSecret)); } }
protected AbstractOAuth2ApiBinding() { this.accessToken = null; this.restTemplate = new Maticsoft.OAuth.Rest.Client.RestTemplate(); ((WebClientHttpRequestFactory) this.restTemplate.RequestFactory).Expect100Continue = false; this.restTemplate.MessageConverters = this.GetMessageConverters(); this.ConfigureRestTemplate(this.restTemplate); }
protected AbstractOAuth2ApiBinding(AccessGrant accessGrant) { this.accessToken = accessGrant.AccessToken; this.restTemplate = new Maticsoft.OAuth.Rest.Client.RestTemplate(); ((WebClientHttpRequestFactory) this.restTemplate.RequestFactory).Expect100Continue = false; this.restTemplate.RequestInterceptors.Add(new OAuth2RequestInterceptor(accessGrant.AccessToken, this.GetOAuth2Version())); this.restTemplate.MessageConverters = this.GetMessageConverters(); this.ConfigureRestTemplate(this.restTemplate); }
protected AbstractOAuth1ApiBinding(string consumerKey, string consumerSecret, string accessToken, string accessTokenSecret) { this.isAuthorized = true; this.restTemplate = new Maticsoft.OAuth.Rest.Client.RestTemplate(); ((WebClientHttpRequestFactory) this.restTemplate.RequestFactory).Expect100Continue = false; this.restTemplate.RequestInterceptors.Add(new OAuth1RequestInterceptor(consumerKey, consumerSecret, accessToken, accessTokenSecret)); this.restTemplate.MessageConverters = this.GetMessageConverters(); this.ConfigureRestTemplate(this.restTemplate); }
public OAuth1Template(string consumerKey, string consumerSecret, string requestTokenUrl, string authorizeUrl, string authenticateUrl, string accessTokenUrl, OAuth1Version version) { ArgumentUtils.AssertNotNull(consumerKey, "consumerKey"); ArgumentUtils.AssertNotNull(consumerSecret, "consumerSecret"); ArgumentUtils.AssertNotNull(requestTokenUrl, "requestTokenUrl"); ArgumentUtils.AssertNotNull(authorizeUrl, "authorizeUrl"); ArgumentUtils.AssertNotNull(accessTokenUrl, "accessTokenUrl"); this.consumerKey = consumerKey; this.consumerSecret = consumerSecret; this.requestTokenUrl = new Uri(requestTokenUrl); this.authorizeUrl = authorizeUrl; this.authenticateUrl = authenticateUrl; this.accessTokenUrl = new Uri(accessTokenUrl); this.version = version; this.restTemplate = this.CreateRestTemplate(); this.signingSupport = new SigningSupport(); }
protected virtual Maticsoft.OAuth.Rest.Client.RestTemplate CreateRestTemplate() { Maticsoft.OAuth.Rest.Client.RestTemplate template = new Maticsoft.OAuth.Rest.Client.RestTemplate(); ((WebClientHttpRequestFactory) template.RequestFactory).Expect100Continue = false; IList<IHttpMessageConverter> list = new List<IHttpMessageConverter>(2); FormHttpMessageConverter item = new FormHttpMessageConverter { SupportedMediaTypes = { MediaType.ALL } }; list.Add(item); list.Add(new SpringJsonHttpMessageConverter()); template.MessageConverters = list; return template; }
protected virtual Maticsoft.OAuth.Rest.Client.RestTemplate CreateRestTemplate() { Maticsoft.OAuth.Rest.Client.RestTemplate template = new Maticsoft.OAuth.Rest.Client.RestTemplate(); IList<IHttpMessageConverter> list = new List<IHttpMessageConverter>(1); FormHttpMessageConverter item = new FormHttpMessageConverter { SupportedMediaTypes = { MediaType.ALL } }; list.Add(item); template.MessageConverters = list; return template; }