Spotify Web API身份验证获取令牌返回无效重定向uri

时间:2017-06-22 13:59:46

标签: http spotify

我试图使用Web API从Spotify获取令牌:

我的原始要求:

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"}

我一定是做错了什么,但我无法弄清楚。任何人都可以帮助我吗?

1 个答案:

答案 0 :(得分:1)

我已经弄清楚了。问题是参数名称redirect_url。它应该是redirect_uri。小错误但是应该打破请求。