【问题标题】:Spotify Web API authentication getting token returns invalid redirect uri获取令牌的 Spotify Web API 身份验证返回无效的重定向 uri
【发布时间】:2017-06-22 13:59:46
【问题描述】:

我正在尝试使用 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"}

我一定是做错了什么,但我想不通。谁能帮帮我?

【问题讨论】:

  • 你的应用注册到 Spotify 了吗?
  • 是的。我在 Spotify 上注册了该应用程序。事实证明它也可以正常工作,因为我确实收到了带有代码的回调。
  • 我也刚刚在此调用中使用无效的重定向 uri 进行了测试。它会给我一个 INVALID CLIENT 错误而不是 invalid_grant
  • 我刚刚测试了发送未编码的重定向 url 时会发生什么,但它会产生相同的响应。

标签: http spotify


【解决方案1】:

我想通了。问题是参数名称redirect_url。它应该是redirect_uri。小错误,但会破坏请求。

【讨论】:

    猜你喜欢
    • 2020-02-17
    • 2018-06-19
    • 1970-01-01
    • 2015-03-01
    • 1970-01-01
    • 2020-07-16
    • 2023-03-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多