【发布时间】:2018-02-11 03:02:10
【问题描述】:
我正在尝试获取访问令牌,以便开始构建与 BigCommerce 一起使用的应用程序。我一直在关注这里的文档:https://developer.bigcommerce.com/api/callback。我正在为 Bigcommerce 使用 PHP 客户端。
响应是 HTTP/1.1 400 Bad Request {"error":"Invalid client id."}。 我发誓我使用的是正确的客户端 ID 和客户端密码!或者至少当我在开发者门户的草稿应用上单击“查看客户端 ID”时显示的是它们。
我到底做错了什么?
$request = $_REQUEST;
require_once 'vendor/autoload.php';
use Bigcommerce\Api\Connection;
$tokenUrl = "https://login.bigcommerce.com/oauth2/token";
$connection = new Connection();
$connection->verifyPeer();
$connection->useUrlencoded();
$response = $connection->post($tokenUrl, array(
"client_id" => "", //I won't type it here but it is correct
"client_secret" => "", //also correct
"redirect_uri" => "https://127.0.0.1/project-custom/oauth.php", //this is the Auth Callback URL
"grant_type" => "authorization_code",
"code" => $request["code"], //when I echo these variables out they work
"scope" => $request["scope"],
"context" => $request["context"],
));
print_r($connection->getLastError());
【问题讨论】:
-
我看到你有 id 的引号,也许删除它们
-
嗯,不,那没用。 :( 从键中删除它们给了我这个通知:“使用未定义的常量 client_id - 假定为'client_id'”并将它们从值中删除只会导致语法错误。
标签: php oauth oauth-2.0 bigcommerce