I am trying to a request a spotify access token using the procedure defined under 'Client Credentials Flow' on the Spotify developer page,
Here is my current implementation (Currently returns http 400 error):
using (var client = new HttpClient())
{
var requestBody = new StringContent(
"grant_type:client_credentials",
Encoding.UTF8,
"application/x-www-form-urlencoded");
var requestEncrypted = Convert.ToBase64String(
Encoding.UTF8.GetBytes(ClientId + ":" + ClientSecret));
client.DefaultRequestHeaders.Add(
"Authorization",
$"Basic {requestEncrypted}");
var tokenResult = await client.PostAsync(TokenEndpoint, requestBody);
}
I have tried other ways for formatting the request body including as json (Note: changing the encoding type to 'application/json' results in a http 415 error (media not supported)