使用 Spotify 客户端 ID 和密码 return 无效客户端卷曲 post 个请求
Curl post requests with Spotify client id & secret return invalid client
我正在关注 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单独编码
- 只有一个或另一个编码
- 都编码为一个带冒号的字符串
- 都编码为一个没有冒号的字符串
- 以上每个都有一个重新生成的客户端密码
我正在使用 Ruby 的 Base64#encode64
方法进行编码。仍然没有运气。有什么有用的提示吗?
好的,我成功了 - 将我的 client_id 和 client_secret 以冒号分隔传递给 Base64.strict_encode64
(不是 Base64.encode64
),然后将其传递给上面的 curl 请求得到一个带有访问令牌的 200 响应。显然 encode64
是不够的。
当我在终端中 运行 curl 命令时,我 运行 遇到了这个错误。
-bash: unexpected EOF while looking for matching `"'
通过使用单引号而不是双引号解决。
我正在关注 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单独编码
- 只有一个或另一个编码
- 都编码为一个带冒号的字符串
- 都编码为一个没有冒号的字符串
- 以上每个都有一个重新生成的客户端密码
我正在使用 Ruby 的 Base64#encode64
方法进行编码。仍然没有运气。有什么有用的提示吗?
好的,我成功了 - 将我的 client_id 和 client_secret 以冒号分隔传递给 Base64.strict_encode64
(不是 Base64.encode64
),然后将其传递给上面的 curl 请求得到一个带有访问令牌的 200 响应。显然 encode64
是不够的。
当我在终端中 运行 curl 命令时,我 运行 遇到了这个错误。
-bash: unexpected EOF while looking for matching `"'
通过使用单引号而不是双引号解决。