获取 AccessToken 时,官网有两种方式,x-www-form-urlencode 和 json 的形式,我直接调接口都跑不通...
x-www-form-urlencoded (Authorization
和redirect_url
做了脱敏处理)
curl --location --request POST 'https://api.login.yahoo.com/oauth2/get_token?code=b9r5j5rbw6vug953442kj9qdnretnrrf' \
--header 'Authorization: Basic ZGoweUptazlXVkpxUTBkS1JIZEdPWHB5Sm1ROVdWZHJPVTlYTVVSUk1uUnVWbTF6YldOSGJ6bE5RVDA5Sm5NOVkyOXVjM1Z0' \
--header 'User-Agent: Apifox/1.0.0 ( https://apifox.com)' \
--header 'Accept: */*' \
--header 'Host: api.login.yahoo.com' \
--header 'Connection: keep-alive' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'code=b9r5j5rbw6vug953442kj9qdnretnrrf' \
--data-urlencode 'redirect_uri=https://test.com/auth' \
--data-urlencode 'grant_type=authorization_code'
返回
{
"error": "INVALID_INPUT",
"error_description": "code parameter cannot be empty for authorization_code grant type"
}
json (client_secret
和redirect_url
做了脱敏处理)
curl --location --request POST 'https://api.login.yahoo.com/oauth2/get_token?code=b9r5j5rbw6vug953442kj9qdnretnrrf' \
--header 'User-Agent: Apifox/1.0.0 ( https://apifox.com)' \
--header 'Content-Type: application/json' \
--header 'Accept: */*' \
--header 'Host: api.login.yahoo.com' \
--header 'Connection: keep-alive' \
--data-raw '{
"client_id": "dj0yJmk9WVJqQ0dKRHdGOXpyJmQ9WVdrOU9XMURRMnRuVm1zbWNHbzlNQT09JnM9Y29uc3VtZXJzZWNyZXQmc3Y9MCZ4PTg0",
"client_secret": "xxxxxxxxxxxxxxxxxxxxxxxxxx",
"redirect_uri": "https://test.com/auth",
"code": "b9r5j5rbw6vug953442kj9qdnretnrrf",
"grant_type": "authorization_code"
}'
返回
{
"error": {
"localizedMessage": "client request is not acceptable or not supported",
"errorId": "INVALID_INPUT",
"message": "client request is not acceptable or not supported"
}
}
client_id
和client_secret
确定是对的,大佬们帮忙看看
1
weofuh 2023-09-05 13:31:55 +08:00
x-www-form-urlencoded 模式,URL 上的 code 参数去掉试试?
|
2
j1132888093 OP @weofuh 我焯!通了,感谢大佬!
|