title: Get Access token from Spotify api
body: <p>I'm trying to get a access token from this endpoint using asp.net: <a href="https://accounts.spotify.com/api/token" rel="nofollow">https://accounts.spotify.com/api/token</a></p>
  
  <p>The token i get back has Status = WaitingForActivation, Method = "{null}", Result = "{Not yet computed}".</p>
  
  <p>When creating my app over att Spotify Developer i stated my Redirect Uri as <a href="http://localhost:59486/" rel="nofollow">http://localhost:59486/</a> which is my Project Url.</p>
  
  <p>What am i doing wrong?</p>
  
  <p>I have borrowed this method from <a href="https://hendrikbulens.wordpress.com/2015/01/07/c-and-the-spotify-web-api-part-i/" rel="nofollow">https://hendrikbulens.wordpress.com/2015/01/07/c-and-the-spotify-web-api-part-i/</a></p>
  
  <pre><code>private async Task&lt;string&gt; GetAccessToken()
          {
              SpotifyToken token = new SpotifyToken();
  
              string postString = string.Format("grant_type=client_credentials");
              byte[] byteArray = Encoding.UTF8.GetBytes(postString);
  
              string url = "https://accounts.spotify.com/api/token";
  
              WebRequest request = WebRequest.Create(url);
              request.Method = "POST";
              request.Headers.Add("Authorization", "Basic YjlkZj****************************************jQ2YjM3MjE5MDE=");
              request.ContentType = "application/x-www-form-urlencoded";
              request.ContentLength = byteArray.Length;
              using (Stream dataStream = request.GetRequestStream())
              {
                  dataStream.Write(byteArray, 0, byteArray.Length);
                  using (WebResponse response = await request.GetResponseAsync())
                  {
                      using (Stream responseStream = response.GetResponseStream())
                      {
                          using (StreamReader reader = new StreamReader(responseStream))
                          {
                              string responseFromServer = reader.ReadToEnd();
                              token = JsonConvert.DeserializeObject&lt;SpotifyToken&gt;(responseFromServer);
                          }
                      }
                  }
              }
              return token.access_token;
          }
  </code></pre>
  
  <p>EDIT:
  This is my Http request:</p>
  
  <pre><code>spotify.com/api/token HTTP/1.1
  Authorization: Basic Yjlk....................5MDE=
  Content-Type: application/x-www-form-urlencoded
  Host: accounts.spotify.com
  Content-Length: 29
  Expect: 100-continue
  Connection: Keep-Alive
  
  grant_type=client_credentials
  </code></pre>