I am trying to call http request using OAuth, but I didn't find a way to create OAuth header to add it to the request.
I used to create new header(signature(RSA SHA1), nonce and timestamp) for each request but I receive unauthorized message every time. HMAC SHA1 is widely used but I didn't find a single example for RSA SHA1.
I tried the following solutions using OAuth.DotNetCore library:
OAuthRequest client= OAuthRequest.ForProtectedResource("GET", settings.ConsumerKey,
settings.key, oauth_token, oauth_secret, OAuth.OAuthSignatureMethod.RsaSha1);
client.RequestUrl = "https://example.com/rest/api/2/user?username=jdoe";
var auth = client.GetAuthorizationHeader();
using (var httpClient = new HttpClient())
{
httpClient.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("OAuth", auth.Remove(0, 6));
string result = httpClient.GetStringAsync("https://example.com
/rest/api/2/user?username=jdoe").Result;
}
Exception Error : RSA SHA1 is only implemented in .NET standard
My project is built using .net framework 4.6.2