public async Task <string> GetToken(string code) { var request = new RestRequest("/api/token", Method.POST); var base64 = SpotifyHelper.Base64Encode($"{AppSettings.ClientId}:{AppSettings.ClientSecret}"); request.AddParameter("code", code); request.AddParameter("redirect_uri", "https://localhost:44320/callback"); request.AddParameter("grant_type", "authorization_code"); request.AddHeader("Content-Type", "application/x-www-form-urlencoded"); request.AddHeader("Authorization", $"Basic {base64}"); IRestResponse response = await Client.ExecutePostTaskAsync <AccessTokenResponse>(request); return(JsonConvert.DeserializeObject <AccessTokenResponse>(response?.Content)?.AccessToken); }