title: Spotify api retrieved access token is not working
body: <p>I am creating a React/C# application with the spotify API, I am receiving an access token but it doesn't work. I get an error (shown below) when trying to make a call to the API (don't know why is says "Invalid username" since it is never used):</p>
  
  <blockquote>
    <p>Error: message: "Invalid username" status: 404</p>
  </blockquote>
  
  <p><code>code</code> is from a earlier step in the authentication process (worked when I used node so I guess that part is correct) and I used all scopes just to be sure that was not a issue <code>playlist-modify-public playlist-modify-private user-read-private user-read-email user-read-playback-state user-read-recently-played</code></p>
  
  <p>My C# code to retrieve the access token:</p>
  
  <pre><code>var spotifyClientId = "id";
  var spotifySecret = "secret";
  
  var webClient = new WebClient();
  
  var postparams = new NameValueCollection();
  postparams.Add("grant_type", "client_credentials");
  postparams.Add("code", code);
  postparams.Add("redirect_uri", "http://localhost:8000/");
  
  //api documentation says you can post clientid/secret in either body or header
  postparams.Add("client_id", spotifyClientId);
  postparams.Add("client_secret", spotifySecret);
  
  //var authHeader = Convert.ToBase64String(Encoding.Default.GetBytes($"{spotifyClientId}:{spotifySecret}"));
  //webClient.Headers.Add(HttpRequestHeader.Authorization, "Basic " + authHeader);
  
  var tokenResponse = webClient.UploadValues("https://accounts.spotify.com/api/token", postparams);
  
  var textResponse = Encoding.UTF8.GetString(tokenResponse);
  
  return Json(textResponse);
  </code></pre>
  
  <p>So I receive this is the response (note access token is very short)</p>
  
  <pre><code>"\"access_token\":\"BQAOYJZnfS0LPEwwZ_06Be76mx59bpoPsVPD0uTvvrwvDtSNi9flgeZQK8kDPSRyTFdE70iBk5PtEAvqnIQ\",\"token_type\":\"Bearer\",\"expires_in\":3600,\"scope\":\"\"}"` 
  </code></pre>
  
  <p>And when I try to call the API with this token, I get the error shown above.</p>
  
  <p>If I manually get the token, I can make API calls from frontend</p>
  
  <p><a href="https://developer.spotify.com/documentation/general/guides/authorization-guide/" rel="nofollow noreferrer">Documentation</a></p>