Я нашел метод для создания сигнатуры Oauth 1.0. Требуется хэширование всех параметров запроса API в алгоритме SHA1.
private string CreateOauthSignature
(string resourceUrl, string oauthNonce, string oauthTimestamp ,
SortedDictionary<string, string> requestParameters)
{
//Add the standard oauth parameters to the sorted list
requestParameters.Add("oauth_consumer_key", consumerKey);
requestParameters.Add("oauth_nonce", oauthNonce);
requestParameters.Add("oauth_signature_method", OauthSignatureMethod);
requestParameters.Add("oauth_timestamp", oauthTimestamp);
requestParameters.Add("oauth_token", accessToken);
requestParameters.Add("oauth_version", OauthVersion);
var sigBaseString = requestParameters.ToWebString();
var signatureBaseString = string.Concat
("GET", "&", Uri.EscapeDataString(resourceUrl), "&",
Uri.EscapeDataString(sigBaseString.ToString()));
//Using this base string, encrypt the data using a composite of the
//secret keys and the HMAC-SHA1 algorithm.
var compositeKey = string.Concat(Uri.EscapeDataString(consumerKeySecret), "&",
Uri.EscapeDataString(accessTokenSecret));
string oauthSignature;
using (var hasher = new HMACSHA1(Encoding.ASCII.GetBytes(compositeKey)))
{
oauthSignature = Convert.ToBase64String(
hasher.ComputeHash(Encoding.ASCII.GetBytes(signatureBaseString)));
}
return oauthSignature;
}
ToWebstring () - это метод расширения для преобразования отсортированного словаря в веб-строку и кодирования специальных символов. После создания подписи ее можно включить в заголовок авторизации запроса Http вместе сдругие параметры заголовка, а именно.одноразовый номер, временная метка, маркер доступа и т. д.