Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OAuth 1.0 with special chars #2126

Open
teunlielu opened this issue Aug 15, 2023 · 1 comment
Open

OAuth 1.0 with special chars #2126

teunlielu opened this issue Aug 15, 2023 · 1 comment
Labels

Comments

@teunlielu
Copy link

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.d__0.MoveNext()
at RestSharp.RestClientExtensions.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.

@teunlielu teunlielu added the bug label Aug 15, 2023
@teunlielu
Copy link
Author

It works over Postman.

alexeyzimarev pushed a commit that referenced this issue Feb 7, 2024
* Fixes OAuth1 signature with special characters (#2126, #1945)

* Adds test for parameters encoding

---------

Co-authored-by: Eleonora Adova <eleonora.adova@riscogroup.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant