Spotify PHP Api-{“错误”:“ unsupported_grant_type”,“错误说明”:“ grant_type参数丢失”}。尝试了一切

时间:2020-09-14 16:52:24

标签: php api sdk spotify

编辑 我发现如果我编辑代码以不使用http_build_query($parameters);

将参数数组转换为url-string,但是将字符串直接传递给它起作用的url。那么 http_build_query 如何破坏 grant_type = authorization_code

原始:

我正在使用php sdk api https://github.com/jwilsson/spotify-web-api-php

并尝试连接用户。我使用链接登录

https://accounts.spotify.com/authorize?
          client_id=--id--
          &redirect_uri=https%3A%2F%2Fwww.testsite.com%2Fspotify_connect%2F
          &response_type=code
          &scope=user-read-email

并获得一个代码作为回报,我已经在Request-> send()

中对代码进行了跟踪

完整链接是

https://accounts.spotify.com/api/token?
client_id=--client--&
code=--returned_code--
&grant_type=authorization_code
&redirect_uri=https%3A%2F%2Fwww.testsite.com%2Fspotify_connect%2F
&client_secret=--secret--

我得到这个回报:

 {"error":"unsupported_grant_type","error_description":"grant_type parameter is missing"}

我也尝试过在标头中发送授权。结果相同

Authorization: Basic base64_encode(--clientid--:--clientsecret--);

我在做什么错了?

使用

https://accounts.spotify.com/api/token?grant_type=client_credentials

就像一种魅力一样工作,但是使用我得到的代码是行不通的。

感谢帮助:)

0 个答案:

没有答案