Sonos API createToken returns a server error

59 Views Asked by At

I have an issue with the createToken API call. I created a Sonos developer and user account and read the documentation on how to authenticate using the API. I created an integration with the redirect uri http://localhost:8080 because I'm still testing it. Doing the getAuthCode call works perfectly after logging in with a user account and I do receive a code.

When using the code and the required params I still get a 400 server_error response without a description even when I try it on the developers docs site.

I would greatly appreciate it if someone can tell me what I'm missing because I can't seem to find what I'm doing wrong.

Curl I tried:

curl --location --globoff --request POST 'https://api.sonos.com/login/v3/oauth/access?grant_type=authorization_code&code={auth_code}&redirect_uri=http%3A%2F%2Flocalhost%3A8080' \
--header 'Content-Type: application/x-www-form-urlencoded;charset=utf-8' \
--header 'Authorization: Basic {Base64 username:password}' \
1

There are 1 best solutions below

1
On

I found the problem, in the documentation they ask for username and password but this is wrong and it should be your integrations client credentials.

curl that works:

curl --location --globoff --request POST 'https://api.sonos.com/login/v3/oauth/access?grant_type=authorization_code&code={auth_code}&redirect_uri=http%3A%2F%2Flocalhost%3A8080' \
--header 'Content-Type: application/x-www-form-urlencoded;charset=utf-8' \
--header 'Authorization: Basic {Base64 client_key:client_secret}' \