RestSharp.Authenticators.OAuth.OAuthWorkflow.BuildRequestTokenInfo C# (CSharp) Méthode

BuildRequestTokenInfo() public méthode

Generates a OAuthWebQueryInfo instance to pass to an IAuthenticator for the purpose of requesting an unauthorized request token.
public BuildRequestTokenInfo ( string method ) : OAuthWebQueryInfo
method string The HTTP method for the intended request
Résultat OAuthWebQueryInfo
        public OAuthWebQueryInfo BuildRequestTokenInfo(string method)
        {
            return BuildRequestTokenInfo(method, null);
        }

Same methods

OAuthWorkflow::BuildRequestTokenInfo ( string method, WebParameterCollection parameters ) : OAuthWebQueryInfo

Usage Example

        private void AddOAuthData(IRestClient client, IRestRequest request, OAuthWorkflow workflow)
        {
            var url = client.BuildUri(request).ToString();

            OAuthWebQueryInfo oauth;
            var method = request.Method.ToString().ToUpperInvariant();

            var parameters = new WebParameterCollection();

            // for non-GET style requests make sure params are part of oauth signature
            if (request.Method != Method.GET && request.Method != Method.DELETE)
            {
                foreach (var p in request.Parameters.Where(p => p.Type == ParameterType.GetOrPost))
                {
                    parameters.Add(new WebPair(p.Name, p.Value.ToString()));
                }
            }

            switch (Type)
            {
                case OAuthType.RequestToken:
                    workflow.RequestTokenUrl = url;
                    oauth = workflow.BuildRequestTokenInfo(method, parameters);
                    break;
                case OAuthType.AccessToken:
                    workflow.AccessTokenUrl = url;
                    oauth = workflow.BuildAccessTokenInfo(method, parameters);
                    break;
                case OAuthType.ClientAuthentication:
                    workflow.AccessTokenUrl = url;
                    oauth = workflow.BuildClientAuthAccessTokenInfo(method, parameters);
                    break;
                case OAuthType.ProtectedResource:
                    oauth = workflow.BuildProtectedResourceInfo(method, parameters, url);
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }

            switch (ParameterHandling)
            {
                case OAuthParameterHandling.HttpAuthorizationHeader:
                    parameters.Add("oauth_signature", oauth.Signature);
                    request.AddHeader("Authorization", GetAuthorizationHeader(parameters));
                    break;
                case OAuthParameterHandling.UrlOrPostParameters:
                    parameters.Add("oauth_signature", HttpUtility.UrlDecode(oauth.Signature));
                    foreach (var parameter in parameters)
                    {
                        request.AddParameter(parameter.Name, parameter.Value);
                    }
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }
        }
All Usage Examples Of RestSharp.Authenticators.OAuth.OAuthWorkflow::BuildRequestTokenInfo