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

0-legged OAuth v1 fails due to RestSharp validation of consumer secret #1597

Closed
patrickhampson opened this issue Jun 17, 2021 · 2 comments
Closed

Comments

@patrickhampson
Copy link
Contributor

Expected Behavior

OAuth1Authenticator.ForAccessToken with a blank consumer secret should still generate the OAuth signature. Happy to submit a PR for this if approved.

Actual Behavior

When setting client authenticator as such:
client.Authenticator = OAuth1Authenticator.ForAccessToken("xx", "", "xxx", "xxxx", OAuthSignatureMethod.PlainText);

You receive an argument null exception thrown by the OAuthWorkflow validation logic for consumer secret. This came up when trying to authenticate against the a 0-legged OAuth (Canonical MAAS API in this instance - https://maas.io/docs/snap/2.9/ui/api-authentication) and causes RestSharp to fail signature validation.

Steps to Reproduce the Problem

1.Create a rest client with an OAuth1Authenticator and a blank consumer secret
2.Execute any request using the client created above
3.Receive ArgumentNullException

Specifications

  • Version:Nuget 106.11.7
  • Platform: .NET Core 3.1

StackTrace

at RestSharp.Validation.Ensure.NotEmpty(String parameter, String name) at RestSharp.Authenticators.OAuth.OAuthWorkflow.ValidateAccessRequestState() at RestSharp.Authenticators.OAuth.OAuthWorkflow.BuildAccessTokenSignature(String method, WebPairCollection parameters) at RestSharp.Authenticators.OAuth1Authenticator.AddOAuthData(IRestClient client, IRestRequest request, OAuthWorkflow workflow) at RestSharp.Authenticators.OAuth1Authenticator.Authenticate(IRestClient client, IRestRequest request) at RestSharp.RestClient.AuthenticateIfNeeded(IRestRequest request) at RestSharp.RestClient.Execute(IRestRequest request, String httpMethod, Func`3 getResponse) at RestSharp.RestClient.Execute(IRestRequest request)
@patrickhampson
Copy link
Contributor Author

Similar to #776

@alexeyzimarev
Copy link
Member

PR merged, hopefully it will work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants