无法从 Bigcommerce API 获取访问令牌,客户端 ID 无效

Can't get access token from Bigcommerce API, invalid client ID

我正在尝试获取访问令牌,以便开始构建可与 BigCommerce 配合使用的应用程序。我一直在关注这里的文档:https://developer.bigcommerce.com/api/callback。我正在为 Bigcommerce 使用 PHP 客户端。

响应是 HTTP/1.1 400 错误请求 {"error":"Invalid client id."}。 我发誓我使用的是正确的客户端 ID 和客户端密码!或者至少当我在开发者门户中点击我的草稿应用程序时 "View Client 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());

我想通了!

我刚刚删除了行 $connection->useUrlencoded();,因为它需要作为 "Content-Type: application/json" 发送,而我将其作为 "Content-Type: application/x-www-form-urlencoded"

发送