I am trying to do this curl call to the new yahoo weather api with OAuth 1 like so:
[HttpGet]
public HttpResponseMessage getWeather()
{
using (HttpClient httpClient = new HttpClient())
{
httpClient.BaseAddress = new Uri("http://weather-ydn-yql.media.yahoo.com/");
httpClient.DefaultRequestHeaders.Accept.Clear();
httpClient.DefaultRequestHeaders.Add("Authorization", "OAuth oauth_consumer_key = \"(MY CONSUMER KEY)\", oauth_signature_method = \"HMAC-SHA1\", oauth_timestamp = \"1547473450\", oauth_nonce = \"Ll7ArdU1yN0\", oauth_version = \"1.0\", oauth_signature = \"(MY GENERATED SIGNATURE FROM POSTMAN)\"");
//httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("OAuth", "oauth_consumer_key = \"(MY CONSUMER KEY)\", oauth_signature_method = \"HMAC-SHA1\", oauth_timestamp = \"1547472939\", oauth_nonce = \"vu3HE92s6A3\", oauth_version = \"1.0\", oauth_signature = \"(MY GENERATED SIGNATURE FROM POSTMAN)\"");
HttpResponseMessage response = httpClient.GetAsync("forecastrss?location=hamilton&format=json").Result;
return response;
}
}
But when I run this it returns this error:
Please provide valid credentials. OAuth oauth_problem="OST_OAUTH_PARAMETER_ABSENT_ERROR", realm="yahooapis.com"
So it appears that my OAuth parameters are missing. My Question is how do I do a curl in ASP.NET C# with OAuth 1 authentication?