예제 #1
0
        public static OAuthRequest GenerateConsumerRequest(OAuthConfig config, Uri requestUri, NameValueCollection requestParams, HttpMethods httpMethod)
        {
            if (config == null)
                throw new ArgumentNullException("config");
            if (requestUri == null)
                throw new ArgumentNullException("requestUri");
            if (requestParams == null)
                requestParams = new NameValueCollection();

            var request = new OAuthRequest();
            request.requestUri = requestUri;
            request.config = config;
            request.httpMethod = httpMethod;
            request.requestType = RequestTypes.ConsumerRequest;

            // Parse any existing URI Params
            request.ParseUriParams(requestUri, requestParams);

            // Assign request params
            request.requestParams = requestParams;

            // Setup required params
            request.requestParams[config.OAuthConsumerKeyKey] = config.OAuthConsumerKey;

            return request;
        }
예제 #2
0
        public static OAuthRequest GenerateConsumerRequest(OAuthConfig config, Uri requestUri, NameValueCollection requestParams, HttpMethods httpMethod)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }
            if (requestUri == null)
            {
                throw new ArgumentNullException("requestUri");
            }
            if (requestParams == null)
            {
                requestParams = new NameValueCollection();
            }

            var request = new OAuthRequest();

            request.requestUri  = requestUri;
            request.config      = config;
            request.httpMethod  = httpMethod;
            request.requestType = RequestTypes.ConsumerRequest;

            // Parse any existing URI Params
            request.ParseUriParams(requestUri, requestParams);

            // Assign request params
            request.requestParams = requestParams;

            // Setup required params
            request.requestParams[config.OAuthConsumerKeyKey] = config.OAuthConsumerKey;

            return(request);
        }
예제 #3
0
        public NameValueCollection GetAccessToken()
        {
            if (this.Config.IsValidForAccessToken())
            {
                var request  = OAuthRequest.GenerateProtectedRequest(this.Config, this.Config.AccessTokenUri, null, OAuthRequest.HttpMethods.GET);
                var response = request.SendRequest();

                var responseParams = HttpUtility.ParseQueryString(response);
                if (responseParams != null && responseParams.Count > 0)
                {
                    Config.OAuthToken = (responseParams[Config.OAuthTokenKey] ?? "");
                    responseParams.Remove(Config.OAuthTokenKey);
                    Config.OAuthTokenSecret = (responseParams[Config.OAuthTokenSecretKey] ?? "");
                    responseParams.Remove(Config.OAuthTokenSecretKey);

                    return(responseParams);
                }
            }
            return(null);
        }
예제 #4
0
 internal string SendConsumerRequest(Uri requestUri, NameValueCollection requestParams, OAuthRequest.HttpMethods httpMethod)
 {
     return OAuthRequest.GenerateConsumerRequest(this.Config, requestUri, requestParams, httpMethod).SendRequest();
 }
예제 #5
0
 public string SendSignedRequest(Uri requestUri, NameValueCollection requestParams, OAuthRequest.HttpMethods httpMethod)
 {
     return OAuthRequest.GenerateSignedRequest(this.Config, requestUri, requestParams, httpMethod).SendRequest();
 }
예제 #6
0
 public string SendProtectedRequest(Uri requestUri, NameValueCollection requestParams, OAuthRequest.HttpMethods httpMethod)
 {
     return(OAuthRequest.GenerateProtectedRequest(this.Config, requestUri, requestParams, httpMethod).SendRequest());
 }
예제 #7
0
 internal string SendConsumerRequest(Uri requestUri, NameValueCollection requestParams, OAuthRequest.HttpMethods httpMethod)
 {
     return(OAuthRequest.GenerateConsumerRequest(this.Config, requestUri, requestParams, httpMethod).SendRequest());
 }
예제 #8
0
 protected internal string SendProtectedRequest(Uri requestUri, NameValueCollection requestParams, OAuthRequest.HttpMethods httpMethod)
 {
     return oauthHandler.SendProtectedRequest(requestUri, requestParams, httpMethod);
 }