14
14
15
15
using System . Web ;
16
16
using RestSharp . Authenticators . OAuth . Extensions ;
17
- using RestSharp . Extensions ;
18
17
19
18
namespace RestSharp . Authenticators . OAuth ;
20
19
@@ -32,11 +31,11 @@ sealed class OAuthWorkflow {
32
31
public string ? SessionHandle { get ; set ; }
33
32
public OAuthSignatureMethod SignatureMethod { get ; set ; }
34
33
public OAuthSignatureTreatment SignatureTreatment { get ; set ; }
35
- // public OAuthParameterHandling ParameterHandling { get; set; }
36
- public string ? ClientUsername { get ; set ; }
37
- public string ? ClientPassword { get ; set ; }
38
- public string ? RequestTokenUrl { get ; set ; }
39
- public string ? AccessTokenUrl { get ; set ; }
34
+ public OAuthParameterHandling ParameterHandling { get ; set ; }
35
+ public string ? ClientUsername { get ; set ; }
36
+ public string ? ClientPassword { get ; set ; }
37
+ public string ? RequestTokenUrl { get ; set ; }
38
+ public string ? AccessTokenUrl { get ; set ; }
40
39
41
40
/// <summary>
42
41
/// Generates an OAuth signature to pass to an
@@ -169,32 +168,24 @@ void ValidateProtectedResourceState() {
169
168
Ensure . NotEmpty ( ConsumerKey , nameof ( ConsumerKey ) ) ;
170
169
}
171
170
172
- WebPairCollection GenerateAuthParameters ( string timestamp , string nonce ) {
173
- var authParameters = new WebPairCollection {
174
- new ( "oauth_consumer_key" , Ensure . NotNull ( ConsumerKey , nameof ( ConsumerKey ) ) ) ,
175
- new ( "oauth_nonce" , nonce ) ,
176
- new ( "oauth_signature_method" , SignatureMethod . ToRequestValue ( ) ) ,
177
- new ( "oauth_timestamp" , timestamp ) ,
178
- new ( "oauth_version" , Version ?? "1.0" )
179
- } ;
180
-
181
- if ( ! Token . IsEmpty ( ) ) authParameters . Add ( new WebPair ( "oauth_token" , Token ! , true ) ) ;
182
-
183
- if ( ! CallbackUrl . IsEmpty ( ) ) authParameters . Add ( new WebPair ( "oauth_callback" , CallbackUrl ! , true ) ) ;
184
-
185
- if ( ! Verifier . IsEmpty ( ) ) authParameters . Add ( new WebPair ( "oauth_verifier" , Verifier ! ) ) ;
186
-
187
- if ( ! SessionHandle . IsEmpty ( ) ) authParameters . Add ( new WebPair ( "oauth_session_handle" , SessionHandle ! ) ) ;
188
-
189
- return authParameters ;
190
- }
171
+ WebPairCollection GenerateAuthParameters ( string timestamp , string nonce )
172
+ => new WebPairCollection {
173
+ new ( "oauth_consumer_key" , Ensure . NotNull ( ConsumerKey , nameof ( ConsumerKey ) ) , true ) ,
174
+ new ( "oauth_nonce" , nonce ) ,
175
+ new ( "oauth_signature_method" , SignatureMethod . ToRequestValue ( ) ) ,
176
+ new ( "oauth_timestamp" , timestamp ) ,
177
+ new ( "oauth_version" , Version ?? "1.0" )
178
+ } . AddNotEmpty ( "oauth_token" , Token ! , true )
179
+ . AddNotEmpty ( "oauth_callback" , CallbackUrl ! , true )
180
+ . AddNotEmpty ( "oauth_verifier" , Verifier ! )
181
+ . AddNotEmpty ( "oauth_session_handle" , SessionHandle ! ) ;
191
182
192
183
WebPairCollection GenerateXAuthParameters ( string timestamp , string nonce )
193
- => new ( ) {
184
+ => new WebPairCollection {
194
185
new ( "x_auth_username" , Ensure . NotNull ( ClientUsername , nameof ( ClientUsername ) ) ) ,
195
186
new ( "x_auth_password" , Ensure . NotNull ( ClientPassword , nameof ( ClientPassword ) ) ) ,
196
187
new ( "x_auth_mode" , "client_auth" ) ,
197
- new ( "oauth_consumer_key" , Ensure . NotNull ( ConsumerKey , nameof ( ConsumerKey ) ) ) ,
188
+ new ( "oauth_consumer_key" , Ensure . NotNull ( ConsumerKey , nameof ( ConsumerKey ) ) , true ) ,
198
189
new ( "oauth_signature_method" , SignatureMethod . ToRequestValue ( ) ) ,
199
190
new ( "oauth_timestamp" , timestamp ) ,
200
191
new ( "oauth_nonce" , nonce ) ,
0 commit comments