Skip to content

Commit 204deea

Browse files
committed
Documentation updates
1 parent d72c6d2 commit 204deea

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

README.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ A tiny, super easy to use OAuth 1.0a library with support for the full OAuth flo
66
## Why?
77
I had to make an API integration against a service provider that still used OAuth 1.0(a) for authorization. I didn't find very many good, easy to use, well documented and small OAuth 1.0a libraries for .NET so I created TinyOAuth1.
88

9+
## Install
10+
Install package from [NuGet](https://www.nuget.org/packages/TinyOAuth1/) or Package Manager Console:
11+
12+
`PM> Install-Package TinyOAuth1`
13+
914
## How does OAuth 1.0a work?
1015
Here's a short explanation of how OAuth 1.0a works and a couple of links with great information.
1116

@@ -85,8 +90,8 @@ var requestTokenInfo = await tinyOAuth.GetRequestToken();
8590
var authorizationUrl = tinyOAuth.GetAuthorizationUrl(requestTokenInfo.RequestToken);
8691

8792
// *** You will need to implement these methods yourself ***
88-
await LaunchWebBrowser(url); // Use Process.Start(url), LaunchUriAsync(new Uri(url)) etc...
89-
var verificationCode = await InputVerificationCode(url);
93+
await LaunchWebBrowser(authorizationUrl); // Use Process.Start(authorizationUrl), LaunchUriAsync(new Uri(authorizationUrl)) etc...
94+
var verificationCode = await InputVerificationCode(authorizationUrl);
9095

9196
// *** Important: Do not run this code before visiting and completing the authorization url ***
9297
var accessTokenInfo = await tinyOAuth.GetAccessToken(requestTokenInfo.RequestToken, requestTokenInfo.RequestTokenSecret,
@@ -107,20 +112,19 @@ To make API calls we need to create an `Authorization: OAuth ...` header and use
107112
#### Using the `TinyOAuthMessageHandler` (recommended)
108113
Will automatically generate and insert the header on each API call.
109114
```cs
110-
HttpClient httpClient =
111-
new HttpClient(new TinyOAuthMessageHandler(config, accessTokenInfo.AccessToken, accessTokenInfo.AccessTokenSecret));
115+
var httpClient = new HttpClient(new TinyOAuthMessageHandler(config, accessTokenInfo.AccessToken, accessTokenInfo.AccessTokenSecret));
112116

113117
// Now we just use the HttpClient like normally
114118
var resp = await httpClient.GetAsync("http://api.provider.com/something/resource?id=12345");
115-
string respJson = await resp.Content.ReadAsStringAsync();
119+
var respJson = await resp.Content.ReadAsStringAsync();
116120
```
117121

118122
#### Manually generating and inserting header
119123
```cs
120-
HttpRequestMessage requestMsg = new HttpRequestMessage();
124+
var requestMsg = new HttpRequestMessage();
121125
requestMsg.Method = new HttpMethod("GET");
122126
requestMsg.RequestUri = new Uri("http://api.provider.com/something/resource?id=12345");
123-
requestMsg.Headers.Authorization = tinyOAuth.GetAuthorizationHeader(...);
127+
requestMsg.Headers.Authorization = tinyOAuth.GetAuthorizationHeader(accessTokenInfo.AccessToken, accessTokenInfo.AccessTokenSecret, requestMsg.RequestUri.AbsolutePath, HttpMethod.Get);
124128
var resp = await httpClient.SendAsync(requestMsg);
125-
string respJson = await resp.Content.ReadAsStringAsync();
129+
var respJson = await resp.Content.ReadAsStringAsync();
126130
```

TinyOAuth1/TinyOAuth1.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
<ItemGroup>
2828
<None Remove=".gitignore" />
29+
<None Remove="pack.bat" />
2930
</ItemGroup>
3031

3132
</Project>

0 commit comments

Comments
 (0)