gpt4 book ai didi

ruby - 使用 Spotify 客户端 ID 和 secret 返回无效客户端的卷发请求

转载 作者:数据小太阳 更新时间:2023-10-29 08:36:06 24 4
gpt4 key购买 nike

我正在关注 Spotify 的 client credentials authorization flow ,但我所有的 curl 请求都返回了 {"error":"invalid_client"}每一次。以下是 Spotify 的说明:

The request will include parameters in the request body:

  • grant_type - Set to “client_credentials”.

The header of this POST request must contain the following parameter:

  • Authorization - A Base 64 encoded string that contains the client ID and client secret key. The field must have the format: Authorization: Basic <base64 encoded client_id:client_secret>

它们还包含一个 curl 请求示例:

$ curl -H "Authorization: Basic ZjM4ZjAw...WY0MzE=" -d grant_type=client_credentials https://accounts.spotify.com/api/token

按照他们的例子,到目前为止,我已经尝试过 curl 请求:

  • client_id 和 client_secret 明文
  • 两个base64分别编码
  • 只编码其中一个
  • 都用冒号编码为一个字符串
  • 都编码为一个没有冒号的字符串
  • 以上每个都有一个重新生成的客户端 key

我正在使用 Ruby 的 Base64#encode64编码的方法。仍然没有运气。有什么有用的提示吗?

最佳答案

好的,我成功了 - 将我的 client_id 和 client_secret(用冒号分隔)传递给 Base64.strict_encode64(不是 Base64.encode64),然后将其传递给上面的 curl 请求得到一个带有访问 token 的 200 响应。显然 encode64 是不够的。

关于ruby - 使用 Spotify 客户端 ID 和 secret 返回无效客户端的卷发请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39423464/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com