Search code examples
c#rest-client

How can I post using the flickr api in c# using Restsharp?


in this code how can i create oauth_signature part in c# using data

By changing the oauth_timestamp and oauth_nonce information on each request and using them on each request how can i create oauth_signature

  public class TestController
{
        [HttpGet("GetFlickr")]
        public ActionResult GetFlickr()
        {
            var client = new RestClient("https://api.flickr.com/services/upload/");
            client.Timeout = -1;
            var request = new RestRequest(RestSharp.Method.POST);
            request.AddHeader("Authorization", "OAuth 
                oauth_consumer_key=\"consumer_key\"," +
                "oauth_token=\"token_key\"," +
                "oauth_signature_method=\"HMAC-SHA1\"," +
                "oauth_timestamp=\"1627559028\"," +
                "oauth_nonce=\"562eiIaQgdi\"," +
                "oauth_version=\"1.0\"," +
                "oauth_callback=\"callback_url\"," +
                "oauth_verifier=\"verifier_key\"," +
                "oauth_signature=\"9xJLlvaSQScgHxiw5AlXtWALuC4%3D\"");
            request.AddFile("photo", "/C:/Users/oguzm/OneDrive/Masaüstü/Ekran Alıntısı.PNG");
            IRestResponse response = client.Execute(request);
            return Ok(response);
        }
}

Solution

  • https://github.com/rhargreaves/oauth-dotnetcore

    using the library here i managed to create signature signing i solved my problem

    I wrote a small library for those who want to use it https://github.com/oguzmolla/FlickrAPILibrary