title: LinkedIn oAuth RequestToken "401 Unauthorized"
body: <p>I am attempting to acquire a RequestToken for the LinkedIn API via oAuth. I have tried numerous things and read all of the documentation I can find related to the topic, and consiquently tried all of the solutions I could think of.</p>
  
  <p>The code I am using is as follows:</p>
  
  <pre><code>    public Dictionary&lt;string, string&gt; GetAccessToken()
      {
  
          Dictionary&lt;string, string&gt; tokens = new Dictionary&lt;string, string&gt;();
          string url = string.Format("https://api.linkedin.com/uas/oauth/requestToken");
          HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
  
          string header = string.Format(@"OAuth oauth_nonce=""{0}"", oauth_signature_method=""{1}"", oauth_timestamp=""{2}"", oauth_consumer_key=""{3}"", oauth_signature=""{4}"", oauth_version=""{5}""",
          HttpUtility.UrlEncode(GenerateNonce()), HttpUtility.UrlEncode(getSignatureMethod()), HttpUtility.UrlEncode(GenerateTimeStamp()), HttpUtility.UrlEncode(getClientID()), HttpUtility.UrlEncode(getClientSecret()), HttpUtility.UrlEncode(getVersion()));
  
          request.Headers.Add("Authorization", header);
          request.Method = "POST";
  
          HRArtis_Security.MyProxy HRProxy = new HRArtis_Security.MyProxy();
          request.Proxy = HRProxy;
          using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
          {
              StreamReader reader = new StreamReader(response.GetResponseStream());
              string retVal = reader.ReadToEnd();
  
              foreach (string token in retVal.Split('&amp;'))
              {
                  tokens.Add(token.Substring(0, token.IndexOf("=")),
                      token.Substring(token.IndexOf("=") + 1, token.Length - token.IndexOf("=") - 1));
              }
          }
          return tokens;
      }
  </code></pre>
  
  <p>I then perform a POST to that URL.
  The error occurs when trying to get the response with the line <code>HttpWebResponse response = request.GetResponse() as HttpWebResponse</code></p>
  
  <p>Another option I tried was adding those parameters to the header with no result.</p>
  
  <p>Am I missing something or being an idiot?</p>