@@ -26,8 +26,53 @@ the values as encoded form values instead.
26
26
27
27
## Basic Authentication
28
28
29
+ The ` HttpBasicAuthenticator ` allows you pass a username and password as a basica auth Authorization header.
30
+
31
+ ``` csharp
32
+ var client = new RestClient (" http://example.com" );
33
+ client .Authenticator = new HttpBasicAuthenticator (" username" , " password" );
34
+ ```
35
+
29
36
## OAuth1
30
37
38
+ For OAuth1 authentication the ` OAuth1Authenticator ` class provides static methods to help generate an OAuth authenticator.
39
+
40
+ ### For endpoints requiring a request token
41
+
42
+ This method requires a ` consumerKey ` and ` consumerSecret ` to authenticate.
43
+
44
+ ``` csharp
45
+ var client = new RestClient (" http://example.com" );
46
+ client .Authenticator = OAuth1Authenticator .ForRequestToken (consumerKey , consumerSecret );
47
+ ```
48
+
49
+ ### For endpoints requiring an access token
50
+
51
+ This method retrieves an access token when provided ` consumerKey ` , ` consumerSecret ` , ` oauthToken ` , and ` oauthTokenSecret ` .
52
+
53
+ ``` csharp
54
+ client .Authenticator = OAuth1Authenticator .ForAccessToken (
55
+ consumerKey , consumerSecret , oauthToken ,
56
+ oauthTokenSecret
57
+ );
58
+ ```
59
+
60
+ This method also includes an optional parameter to specity the ` OAuthSignatureMethod ` .
61
+ ``` csharp
62
+ client .Authenticator = OAuth1Authenticator .ForAccessToken (consumerKey ,
63
+ consumerSecret ,
64
+ oauthToken ,
65
+ oauthTokenSecret ,
66
+ OAuthSignatureMethod .PlainText );
67
+ ```
68
+
69
+ ### 0-legged OAuth
70
+
71
+ The same access token authenticator can be used in 0-legged OAuth scenarios by providing ` null ` for the ` consumerSecret ` .
72
+ ``` csharp
73
+ client .Authenticator = OAuth1Authenticator .ForAccessToken (consumerKey , null , oauthToken , oauthTokenSecret );
74
+ ```
75
+
31
76
## JWT
32
77
33
78
## Custom Authenticator
0 commit comments