-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
OAuth1 signature is generated incorrectly when using non-ASCII symbols in request parameters #1945
Labels
Comments
I experience the same issue. Any update on it? |
@elia936 it's an open source project, if you experience this issue please feel free to submit a pull request to fix it. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
elia936
added a commit
to elia936/RestSharp
that referenced
this issue
Aug 16, 2023
4 tasks
alexeyzimarev
pushed a commit
that referenced
this issue
Feb 7, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
If we use OAuth1 authentication (
restClient.Authenticator = OAuth1Authenticator.ForProtectedResource(...)
) and have some non-ASCII symbols in our request parameters (it failed when using '£') oauth_signature is generated not correctly.I think this is because you skipped part of OAuth1 algorithm where we encode our params to UTF-8, it should be done before we URL-encode them. Here is the method that is doing URL-encode:
RestSharp/src/RestSharp/Authenticators/OAuth/OAuthTools.cs
Line 137 in 79848da
To Reproduce
Imagine we have a param:
products=[{"id":5,"price":"£55"}]
Currently we are just URL-encoding it using this line:
RestSharp/src/RestSharp/Authenticators/OAuth/OAuthTools.cs
Line 121 in 79848da
In the end we have something like this:
products%3D%5B%7B%22id%22%3A5%2C%22price%22%3A%22%A355%22%7D%5D
Expected behavior
Starting param:
products=[{"id":5,"price":"£55"}]
After UTF-8 encode (e.g. using this site https://cafewebmaster.com/online_tools/utf8_encode) we should have this:
products=[{"id":5,"price":"£55"}]
And only after that we need to URL-encode it:
products%3D%5B%7B%22id%22%3A5%2C%22price%22%3A%22%C2%A355%22%7D%5D
The difference is we have
%C2%A3
instead of%A3
.Desktop:
Additional context
There is a very useful site for OAuth1 that helped me to find a problem. This is a sandbox that shows the algorithm to generate signature step by step: http://lti.tools/oauth/
The text was updated successfully, but these errors were encountered: