1
我试图通过他们的新REST API连接到eBay API。易趣REST API:invalid_request当交换访问令牌的授权码
我正在使用一个非常简单的脚本来测试流程,并且我正在使用Guzzle。
我遵循的指南是this。
但是,当它的时间,我曾经收到以下消息的访问令牌兑换授权码:
{"error":"invalid_request","error_description":"request is invalid","error_uri":null}
我真的不知道,试图使这项工作是什么。
这是我使用的代码:
<?php
...
if (isset($_GET['code'])) {
$client = new \GuzzleHttp\Client();
$authorization = base64_encode($appId . ':' . $certId);
$code = urlencode($_GET['code']);
$body = 'grant_type=authorization_code&code=' . $code . '&redirect_uri=' . $ruName;
$options = [
\GuzzleHttp\RequestOptions::HEADERS => [
'Content-Type' => 'application/x-www-form-urlencoded',
'Authorization' => 'Basic ' . $authorization,
],
\GuzzleHttp\RequestOptions::BODY => $body,
\GuzzleHttp\RequestOptions::DEBUG => true,
];
try {
$response = $client->post('https://api.sandbox.ebay.com/identity/v1/oauth2/token', $options);
die(dump($response->getBody()->__toString(), $response));
} catch (\Exception $e) {
die(dump($e,$_GET, $authorization, $body, $options));
}
}
// Start the authentication redirecting the user to the eBay's sign-in page
$get_request_token_url = 'https://signin.sandbox.ebay.com/authorize'
. '?client_id=' . $appId
. '&redirect_uri=' . $ruName
. '&response_type=code'
// Scope for User
. '&scope=' . urlencode(
'https://api.ebay.com/oauth/api_scope '.
'https://api.ebay.com/oauth/api_scope/sell.account.readonly '.
'https://api.ebay.com/oauth/api_scope/sell.account '
);
header('Location: ' . $get_request_token_url);
由于文档是ambigous,我也试着设置由易趣直接在查询字符串返回导通时间/临时code
(带所有其他参数应该在body
)。我也试过把它们都发送到body
并附加到query_string
,但似乎没有任何工作...
我真的不知道还有别的什么尝试。
任何人都可以帮忙吗?
嗨,它运行良好,你能解释如何生成令牌 –
您好奥洛洛,你可以发送代码。我试图得到令牌,与代码生成,它kepp说invalid_request –
@manokarthickkarthick,写一个新的问题,并从这里链接:我们会帮助你... – Aerendir