# Problem after connecting Mautic 3 via PHP with the API

**URL:** <https://forum.mautic.org/t/problem-after-connecting-mautic-3-via-php-with-the-api/26565>\
**Category:** Product Support\
**Tags:** mautic-3\
**Created:** [January 2, 2023, 12:05pm UTC](https://forum.mautic.org/t/problem-after-connecting-mautic-3-via-php-with-the-api/26565 "2023-01-02T12:05:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pramirez](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/pramirez/32/1504_2.png) [@pramirez](https://forum.mautic.org/u/pramirez)\
**Post date:** [January 2, 2023, 12:05pm UTC](https://forum.mautic.org/t/problem-after-connecting-mautic-3-via-php-with-the-api/26565/1 "2023-01-02T12:05:03Z")

</div>

**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](https://developer.mautic.org/#oauth-1a)”.

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

![image](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/4/4e18f26c8ccb75af85c05e39658b4ada95205061.png)

![image](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/b/b1330d8a1ea8722ad0a111e0d1b0109933c8fa82.png)

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

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

$baseUrl = "https://mautic.ebvconsulting.com";
$clientKey = "xxxxxxxxxxxxxxxx";
$clientSecret = "xxxxxxxxxxxxxxxx";
$callback = 'https://ventas.autenticonuevayork.com/vendor/mautic';

// 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:

```auto
[Mon Jan 02 13:02:14.066226 2023] [proxy_fcgi:error] [pid 24594:tid 139871515539200] [client 79.145.16.220:47084] 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.
