ruby-on-railsrubycurloauth-2.0beatsmusic

token requests always results in "Authorization code is invalid."


Seems no matter what I do, requesting a token I always get the Authorization code is invalid. response. I have tried this both in Ruby code and via Curl.

curl -X POST https://partner.api.beatsmusic.com/oauth2/token -d client_secret=SECRET -d client_id=MYID -d redirect_uri=http://foo.example.com/auth/beats_oauth2 -d code=rjmsqtgntc5k6s8jhdawpu4c  

results in:

{"code":"InvalidCredentials","message":"Authorization code is invalid."}

Same results for the RoR code.

any suggestions would be great as I have been working on this for a few days!

thanks! Gary


Solution

  • The issue was the redirect URL on the getToken request was wrong. The callback I set in the Beats Music API config was "/auth/beats_oauth2/callback" but in the my code and the above example Curl I only had "/auth/beats_oauth2". I can't believe I looked at that a million times... Of course the invalid access code error message made me think it was not related to the redirect url. But that's another story.