I'm trying to make a token request using guzzle and receive an error "400 Bad Request` response: {"error":"invalid_client"}". I can make the same request with cURL and HTTP_Request2 with no problem.
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Psr7\Request;
session_start();
if(isset($_GET['code'])){
$code = $_GET['code'];
$encodeB64 = base64_encode('{clientID}:{clientSecret}');
$client = new GuzzleHttp\Client();
$response = $client->request('POST', 'https://identity.reckon.com/connect/token',[
['headers' => ['Content-Type' => 'application/x-www-form-urlencoded'],['Authorization' => 'Basic '.$encodeB64]],
['body' => ['grant_type' => 'authorization_code'],['code' => $code],['redirect_uri' => '{redirectURI}']]
]);
$body = $response->getBody();
echo $body;
}
These are the details of how to make a token request with this API:
URL: https://identity.reckon.com/connect/token
Type: POST
Body: grant_type=authorization_code&code={code}&redirect_uri={redirect url}
Headers:
Content-Type = application/x-www-form-urlencoded
Authorization: Basic{client id:client secret encoded in base64}
Not sure where I'm going wrong.