Reputation: 1931
I'm following Spotify's client credentials authorization flow, but all of my curl requests are returning {"error":"invalid_client"}
each time. Here are the instructions from Spotify:
The request will include parameters in the request body:
- grant_type - Set to “client_credentials”.
The header of this POST request must contain the following parameter:
- Authorization - A Base 64 encoded string that contains the client ID and client secret key. The field must have the format:
Authorization: Basic <base64 encoded client_id:client_secret>
They also include an example of a curl request:
$ curl -H "Authorization: Basic ZjM4ZjAw...WY0MzE=" -d grant_type=client_credentials https://accounts.spotify.com/api/token
Following their example, so far I've tried curl requests with:
I'm using Ruby's Base64#encode64
method to encode. Still no luck. Any helpful hints?
Upvotes: 2
Views: 2381
Reputation: 171
I ran into this error when I ran the curl command in my terminal.
-bash: unexpected EOF while looking for matching `"'
Solved by using single quotes instead of double quotes.
Upvotes: 0
Reputation: 1931
Okay, I got it working - passing my client_id and client_secret, separated by a colon, to Base64.strict_encode64
(NOT Base64.encode64
) and then passing that to the above curl request gets a 200 response with an access token. Apparently encode64
was not enough.
Upvotes: 4