【发布时间】:2020-04-25 19:06:24
【问题描述】:
我正在尝试了解 OAuth,并决定使用 eBay API。在关注他们的 instructions 以获取应用程序访问令牌时,我收到了 400 错误。
library(jsonlite)
library(httr)
# OAuth credentials
client_id <- "x"
client_secret <- "x"
# Required - https://developer.ebay.com/api-docs/static/oauth-base64-credentials.html
encod_oauth <- base64_enc(paste0(client_id, ":", client_secret))
auth_token_res <-
POST("https://api.sandbox.ebay.com/identity/v1/oauth2/token",
add_headers("Content-Type" = "application/x-www-form-urlencoded",
Authorization = paste0("Basic ", encod_oauth)),
body = list(grant_type = "client_credentials",
scope = urlEncode("https://api.ebay.com/oauth/api_scope", reserved = T)))
检查内容,这显然与正文中的grant_type有关。
content(auth_token_res)
$error_description
[1] "grant type in request is not supported by the authorization server"
正文请求有什么问题,为什么?
【问题讨论】:
-
都试过了,都没有成功,谢谢。
-
content(auth_token_res)抛出同样的错误。 -
也尝试了 cURL,但出现错误:
{"error":"invalid_request","error_description":"request is missing a required parameter or malformed."}(base)。认为联系支持可能是最好的选择。 -
可能API手册没有更新
标签: r post oauth-2.0 ebay-api httr