Problem after connecting Mautic 3 via PHP with the API

Your software
My Mautic version is: 3.3.0
My PHP version is: 7.4.33
My Database type and version is: MariaDB 10.1

Your problem
My problem is: I’ve correctly installed Mautic API via Composer v2.5.1. Now I’m trying to follow the steps to try the connection between my PHP and Mautic from “Mautic Developer Documentation”.

  1. I made the setup of the credentials in Mautic and I put the URI callback where I installed the mautic API installed.



Now, I’m trying via PHP to test the connection and the credentials, but it’s not working.

require_once (dirname( __FILE__ ) . '/vendor/autoload.php' );
use Mautic\Auth\ApiAuth;

$baseUrl = "";
$clientKey = "xxxxxxxxxxxxxxxx";
$clientSecret = "xxxxxxxxxxxxxxxx";
$callback = '';

// Build the full API url
//$apiUrl = $baseUrl . "/api/contacts";

// $initAuth->newAuth() will accept an array of OAuth settings
$settings = array(
	'baseUrl'      => $baseUrl,
	'version'      => 'OAuth1a',
	'clientKey'    => $clientKey,
	'clientSecret' => $clientSecret, 
	'callback'     => $callback

// Initiate the auth object
$initAuth = new ApiAuth();
$auth     = $initAuth->newAuth($settings);

// Initiate process for obtaining an access token; this will redirect the user to the authorize endpoint and/or set the tokens when the user is redirected back after granting authorization

$respuesta = $auth->validateAccessToken();
print_r ($respuesta);

if ($auth->validateAccessToken()) {
	if ($auth->accessTokenUpdated()) {
		$accessTokenData = $auth->getAccessTokenData();

		//store access token data however you want

These errors are showing in the log:

[Mon Jan 02 13:02:14.066226 2023] [proxy_fcgi:error] [pid 24594:tid 139871515539200] [client] AH01071: Got error 'PHP message: PHP Fatal error:  Uncaught Mautic\\Exception\\UnexpectedResponseFormatException: The response has unexpected status code (403).\n\nResponse: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">\n<html><head>\n<title>403 Forbidden</title>\n</head><body>\n<h1>Forbidden</h1>\n<p>You don't have permission to access this resource.</p>\n</body></html>\n in /home/ventasautenticonuevayork/www/vendor/mautic/api-library/lib/Response.php:172\nStack trace:\n#0 /home/ventasautenticonuevayork/www/vendor/mautic/api-library/lib/Response.php(31): Mautic\\Response->validate()\n#1 /home/ventasautenticonuevayork/www/vendor/mautic/api-library/lib/Auth/AbstractAuth.php(178): Mautic\\Response->__construct('HTTP/1.1 403 Fo...', Array)\n#2 /home/ventasautenticonuevayork/www/vendor/mautic/api-library/lib/Auth/OAuth.php(736): Mautic\\Auth\\AbstractAuth->makeRequest('https://mautic....', '[]', 'POST', Array)\n#3 /home/ventasautenticonuevayork/www/vendor/mautic/api-library/lib/Auth/OAuth.php(408): Mautic\\Auth\\OAuth->requestToken()\n#4 /home/ve...'

Thank you so much for the help.