Pregunta

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

¿Fue útil?

Solución

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.

Otros consejos

Is it possible that your authorization code has expired? I see here that they are only valid for 1 hr and then need to be refreshed. Instructions to do so are also at that link.

The example from the docs also shows a -d grant_type=authorization_code parameter being sent. Have you tried it with that param included?

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top