Skip to content

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

@patrickhampson

Description

@patrickhampson

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

Details 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions