2

I am trying to follow the basic tutorial provided by Spotify here, but I am getting the following error when I try to authenticate:

2014-12-20 15:32:18.526 SpotifyTest[18319:53463120] *** Auth error: Error Domain=com.spotify.auth
Code=400 "Invalid client" UserInfo=0x7fcbb84c1e40 {NSLocalizedDescription=Invalid client}

What I have done:

  1. My token exchange service is deployed to Heroku. I used this app. I have confirmed that the service is running.
  2. I have triple checked that my Client Id, Client Secret, and callback URI are the same everywhere.(i.e. Spotify Developer Interface, Token Exchange Service, AppDelegate).
  3. Linker Flags = "-all_load -ObjC" (I added the all_load flag to fix this problem)
  4. URL Types = my callback URI excluding "://callback"

Log from my Token Exchange Service:

2014-12-20T21:32:18.347945+00:00 heroku[router]: at=info method=POST path="/swap" host=hidden-brushlands-8320.herokuapp.com request_id=903792bf-561d-4635-be85-5b1f27676afa fwd="<ipAddress>" dyno=web.1 connect=1ms service=407ms status=400 bytes=349
2014-12-20T21:32:18.347480+00:00 app[web.1]: <ipAddress> - - [20/Dec/2014 21:32:18] "POST /swap HTTP/1.1" 400 63 0.4018
2014-12-20T21:32:18.347821+00:00 app[web.1]: ip-10-87-143-248.ec2.internal - - [20/Dec/2014:21:32:17 UTC] "POST /swap HTTP/1.1" 400 63
2014-12-20T21:32:18.347865+00:00 app[web.1]: - -> /swap

I've never really done iOS development before, I just was interested in playing around with the Spotify sdk so let me know if there is any other relevant information I can provide.

Community
  • 1
  • 1

1 Answers1

3

I was in the exact situation and could not figure out how to make it work. I finally realized that after changing the spotify_token_swap.rb file to the correct Client ID, secret, and callback URI, I had not yet committed my changes. The fix was to do the following:

git add .
git commit -m "commit message"
git push heroku master

Also make sure you are testing on a device and not on the simulator (which will use the localhost URL for the swap service URL)

user3781236
  • 728
  • 2
  • 9
  • 23
  • I checked that everything was committed and pushed to heroku. I was running from a simulator, and my request is reaching the token service as the logs show. The service is returning the 400 "Invalid Client" error. – philosowaffle Jan 24 '15 at 21:38
  • @philosowaffle Like I said, try on your device, as the simulator will use the localhost URL – user3781236 Jan 26 '15 at 17:33