2017-06-22 49 views
0

我试图使用Web API从Spotify的令牌:Spotify的网络API认证令牌获得回报无效重定向URI

我的原始请求:

POST https://accounts.spotify.com/api/token HTTP/1.1 
Authorization: Basic [authsecret] 
Content-Type: application/x-www-form-urlencoded 
Host: accounts.spotify.com 
Content-Length: 490 
Expect: 100-continue 
Connection: Keep-Alive 

grant_type=authorization_code&code=[code]&redirect_url=http%3A%2F%2Flocalhost%3A53575%2FSpotifyLogin.aspx 

其中[AUTHSECRET]被替换所需的字符串(这是打破了,给了我一个不同的错误,但现在我已经修复了它)并且[code]被Spotify之前返回的代码替换了。

我得到如下回应:

HTTP/1.1 400 Bad Request 
Server: nginx 
Date: Thu, 22 Jun 2017 13:50:33 GMT 
Content-Type: application/json 
Content-Length: 68 
Connection: keep-alive 
Keep-Alive: timeout=600 

{"error":"invalid_grant","error_description":"Invalid redirect URI"} 

我必须做一些错误,但我无法弄清楚。谁能帮我?

+0

您的应用是否已注册到Spotify? –

+0

是的。我使用Spotify注册​​了该应用程序。事实证明它也可以工作,因为我确实收到了代码的回调。 –

+0

我也刚刚在这个调用中用一个无效的重定向uri进行了测试。它会给我一个无效的客户端错误,而不是invalid_grant –

回答

1

我已经想通了。问题是参数名称redirect_url。它应该是redirect_uri。小错误,但应该打破它的要求。