How can I get an access token Spotify API?
<p>I've been looking at the Spotify api for a few days now and example source code and I still can't figure out how to get an access token to access a user's playlist data. I've gotten to the point where I pull up the login window, the user logs in, and then I receive an authorization code. At this point, I tried doing things like:</p>

<pre><code>window.open("https://accounts.spotify.com/api/token?
grant_type=authorization_code&amp;code="+code+"&amp;redirect_uri=myurl&amp;client_id=3137b15
2f1424defa2c6020ae5c6d444&amp;client_secret=mysecret");
</code></pre>

<p><strong>and</strong> </p>

<pre><code>$.ajax(
    {
      url: "https://accounts.spotify.com/api/token?grant_type=authorization_code&amp;code="+code+"&amp;redirect_uri=myurl&amp;client_secret=mysecret&amp;client_id=myid", 
      success: function(result){
        alert("foo");
      }
    }
);
</code></pre>

<p>But either way I get a result like: </p>

<pre><code>{"error":"server_error","error_description":"Unexpected status: 405"}
</code></pre>

<p>instead of a token. I'm sure this is simple but I'm terrible at JS. Please help! Thank you! </p>

<p><strong>(edit) I forgot to mention:</strong></p>

<p>Link to api authentication guide: <a href="https://developer.spotify.com/web-api/authorization-guide/" rel="noreferrer">https://developer.spotify.com/web-api/authorization-guide/</a></p>

<p>I'm stuck on step 4. I see that there is an alternative method on sending a "header parameter" or cURL request which might work. But seing as how I have no idea how to do these things I've stuck with sending the client_id and client_secret as body request parameters like I did before for the user login/code. </p>

<p>PS: I'm only using this application I'm writing for myself. Is there a way I could hardcode a token in without going through this process instead?</p>