Skip to content

OAuth 1.0 with special chars #2126

Description

@teunlielu

DO NOT USE ISSUES FOR QUESTIONS

Describe the bug
If you use special characters like: éèç you get error authentication fail.

HttpRequestException: Request failed with status code Unauthorized

To Reproduce

Example code was VB convert to C# for faster responce:
Removed code not important to report the bug.
AddParameter or AddqeuryParameter no difference

using RestSharp;
using RestSharp.Authenticators;
using RestSharp.Authenticators.OAuth;

internal static partial class Program
{

    private const string consumer_key = "*******";
    private const string consumer_secret = "*******";
    private const string access_token = "*******";
    private const string token_secret = "*******";
   private const string URL = "https://example.com";

    public static void Main(string[] args)
    {
        var authenticator = OAuth1Authenticator.ForAccessToken(consumer_key, consumer_secret, access_token, token_secret, OAuthSignatureMethod.HmacSha256);


        var options = new RestClientOptions()
        {
            authenticator = authenticator,
            ThrowOnAnyError = true
        };

        RestResponse response = default;
        RestRequest request = default;

            var client = new RestClient(options);
            request = new RestRequest(URL, Method.Get);
            request.AddParameter("filter", @"éèç");
  
            request.AddHeader("Content-Type", "application/json");
            response = client.GetAsync(request).Result;
        Console.WriteLine(response.Content);
        Console.ReadKey();
    }
} 

Expected behavior
Request returns desired search result

Stack trace

Request failed with status code Unauthorized
   at RestSharp.RestClient.<ExecuteAsync>d__0.MoveNext()
   at RestSharp.RestClientExtensions.<GetAsync>d__14.MoveNext()

Desktop (please complete the following information):

  • OS: [e.g. Windows 10]
  • .NET version [e.g. .NET 6]
  • Server to reqeust Linux server.

Additional context
Add any other context about the problem here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions