Skip to content
Go to file
This branch is 19 commits behind neuecc:master.

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


Portable Client Library and HttpClient based OAuth library, including all platform(for PCL as .NET 4.0, .NET 4.5, Silverlight4, Silverlight5, Windows Phone 7.5, Windows Phone 8.0, Windows Store Apps).


using with NuGet, AsyncOAuth

PM> Install-Package AsyncOAuth


at first, you must initialize hash function(ApplicationStart etc...)

// Silverlight, Windows Phone, Console, Web, etc...
OAuthUtility.ComputeHash = (key, buffer) => { using (var hmac = new HMACSHA1(key)) { return hmac.ComputeHash(buffer); } };
// Windows Store Apps
AsyncOAuth.OAuthUtility.ComputeHash = (key, buffer) =>
    var crypt = Windows.Security.Cryptography.Core.MacAlgorithmProvider.OpenAlgorithm("HMAC_SHA1");
    var keyBuffer = Windows.Security.Cryptography.CryptographicBuffer.CreateFromByteArray(key);
    var cryptKey = crypt.CreateKey(keyBuffer);
    var dataBuffer = Windows.Security.Cryptography.CryptographicBuffer.CreateFromByteArray(buffer);
    var signBuffer = Windows.Security.Cryptography.Core.CryptographicEngine.Sign(cryptKey, dataBuffer);
    byte[] value;
    Windows.Security.Cryptography.CryptographicBuffer.CopyToByteArray(signBuffer, out value);
    return value;

Create HttpClient with OAuthMessageHandler

var client = new HttpClient(new OAuthMessageHandler("consumerKey", "consumerSecret", new AccessToken("accessToken", "accessTokenSecret")));
// shorthand(result is same above)
var client = OAuthUtility.CreateOAuthClient("consumerKey", "consumerSecret", new AccessToken("accessToken", "accessTokenSecret"));

operation same as HttpClient

// Get
var json = await client.GetStringAsync("" + count + "&page=" + page);
// Post
var content = new FormUrlEncodedContent(new[] { new KeyValuePair<string, string>("status", status) });
var response = await client.PostAsync("", content);
var json = await response.Content.ReadAsStringAsync();
// Multi Post
var content = new MultipartFormDataContent();
content.Add(new StringContent(status), "\"status\"");
content.Add(new ByteArrayContent(media), "media[]", "\"" + fileName + "\"");
var response = await client.PostAsync("", content);
var json = await response.Content.ReadAsStringAsync();


more sample, please see AsyncOAuth.ConsoleApp(Twitter.cs, Hatena.cs), AsyncOAuth.WindowsStoreApp
sample contains authorize flow

// sample flow for Twitter authroize
public async static Task<AccessToken> AuthorizeSample(string consumerKey, string consumerSecret)
    // create authorizer
    var authorizer = new OAuthAuthorizer(consumerKey, consumerSecret);

    // get request token
    var tokenResponse = await authorizer.GetRequestToken("");
    var requestToken = tokenResponse.Token;

    var pinRequestUrl = authorizer.BuildAuthorizeUrl("", requestToken);

    // open browser and get PIN Code

    // enter pin
    Console.WriteLine("ENTER PIN");
    var pinCode = Console.ReadLine();

    // get access token
    var accessTokenResponse = await authorizer.GetAccessToken("", requestToken, pinCode);

    // save access token.
    var accessToken = accessTokenResponse.Token;
    Console.WriteLine("Key:" + accessToken.Key);
    Console.WriteLine("Secret:" + accessToken.Secret);

    return accessToken;


ver 0.7.0 - 2013-06-24

  • fixed, generate wrong OAuth signature when parameter-name mixed lower and upper.
  • fixed, generate wrong OAuth signature when get and querystring needs UrlEncode

ver.0.6.4 - 2013-05-27

  • update external library version.
  • improved:Token is serializable.


under MIT License


Portable Client Library and HttpClient based OAuth library, including all platform(for PCL).



No releases published
You can’t perform that action at this time.