title: Invalid signature for signing requests to the Flickr API (simulation in console)
body: <p>I'm trying to authenticate to the Flickr API for a demo application I want to make for myself. Then i will extend this app with new features that i'll learn of the Flick API's.</p>
  
  <p>So this is just something i want to play with. But now I have some trouble in getting a request token. </p>
  
  <p>I'm following the Flickr Authentication documentation here: <a href="http://www.flickr.com/services/api/auth.oauth.html" rel="noreferrer">Flickr Authentication</a><br>
  And i also found this Mathlabscript: <a href="http://www.mathworks.com/matlabcentral/fileexchange/34162-flickr-api-with-oauth-based-user-authentication/content/html/testFlickrApi.html" rel="noreferrer">Flickr API with OAuth-based user authentication</a> </p>
  
  <p>So based on these sources i have now the following console application:</p>
  
  <pre><code>class Program
  {
      private static string Secret = "2b2b2b2b2b2b2b2b2b";
      private static string ConsumerKey = "1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a";
  
      static void Main(string[] args)
      {
          Random rand = new Random();
  
          string nonce = rand.Next(9999999).ToString();
          string timestamp = ((int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds).ToString();
  
          Console.WriteLine("Nonce: " + nonce);
          Console.WriteLine("TimeStamp: " + timestamp);
  
          Console.WriteLine("ConsumerKey: " + ConsumerKey);
          Console.WriteLine("AppSecret: " + Secret);
  
          //request url
          StringBuilder b = new StringBuilder();
          b.Append("http://www.flickr.com/services/oauth/request_token");
          b.Append("?");
          b.Append("oauth_nonce=");
          b.Append(nonce);
          b.Append("&amp;oauth_timestamp=");
          b.Append(timestamp);
          b.Append("&amp;oauth_consumer_key=");
          b.Append(ConsumerKey);
          b.Append("&amp;oauth_callback=oob");
          b.Append("&amp;oauth_signature_method=HMAC-SHA1");
  
          string requesturl = b.ToString();
          Console.WriteLine("RequestUrl: " + requesturl);
  
          //base url
          string basestring;
          StringBuilder bs = new StringBuilder();
  
          bs.Append("GET&amp;");
          bs.Append(UrlHelper.Encode("http://www.flickr.com/services/oauth/request_token")+"&amp;");
          basestring = bs.ToString();
  
          StringBuilder p = new StringBuilder();
          p.Append("oauth_callback=oob");
          p.Append("&amp;oauth_consumer_key=");
          p.Append(ConsumerKey);
          p.Append("oauth_nonce=");
          p.Append(nonce);
          p.Append("&amp;oauth_signature_method=HMAC-SHA1");
          p.Append("&amp;oauth_timestamp=");
          p.Append(timestamp);
  
          string paramers = UrlHelper.Encode(p.ToString());
  
          basestring += paramers;
          Console.WriteLine("Basestring: " + basestring);
  
  
  
          System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
  
          string key = Secret + "&amp;";
          Console.WriteLine("Key: " + key);
  
          byte[] keyByte = encoding.GetBytes(key);
  
          //--create message to encrypt
          byte[] messageBytes = encoding.GetBytes(basestring);
  
          //--encrypt message using hmac-sha1 with the provided key
          HMACSHA1 hmacsha1 = new HMACSHA1(keyByte);
          byte[] hashmessage = hmacsha1.ComputeHash(messageBytes);
  
          //--signature
          string signature = ByteToString(hashmessage);
          Console.WriteLine("Signature: " + signature);
  
          Console.WriteLine("Final Request: " + requesturl + "&amp;oauth_signature=" + signature);  
  
  
          Console.ReadKey(true);
  
  
  
      }
      public static string ByteToString(byte[] buff)
      {
          string sbinary = "";
  
          for (int i = 0; i &lt; buff.Length; i++)
          {
              sbinary += buff[i].ToString("X2"); // hex format
          }
          return (sbinary);
      }
  }
  </code></pre>
  
  <p>When i browse to the url this applications give me, i get the following response:</p>
  
  <pre><code>oauth_problem=signature_invalid&amp;debug_sbs=GET&amp;http%3A%2F%2Fwww.flickr.com%2Fservices%2Foauth%2Frequest_token&amp;oauth_callback%3Dhttp%253A%252F%252Fwww.google.be%26oauth_consumer_key%3D1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a%26oauth_nonce%3D27504343%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1329469580
  </code></pre>
  
  <p>It seems that my signature for the request is invalid. </p>
  
  <p>I hope someone can help me get the right signature for these requests.</p>
  
  <p>I know there is a FlickNet Library that already did the hard work for most of the developers but i think it can be useful to get this working too. I looked into the source code of FlickrNet but didn't find the final peace to complete this code. </p>
  
  <p>Let me know if you can help me. It would be so great!</p>
  
  <p>Thanks!</p>