Attempted to call an undefined method named "validateAccessToken" when using Mautic api-library in Symfony
request.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\UndefinedMethodException: "Attempted to call an undefined method named "validateAccessToken" of class "Mautic\Auth\ApiAuth"
Means the method validateAccessToken
doesn't exist in Mautic\Auth\ApiAuth
, indeed it's not defined there but in Mautic\Auth\OAuth
.
// Mautic\Auth\ApiAuthpublic function newAuth($parameters = array(), $authMethod = 'OAuth'){ $class = 'Mautic\\Auth\\'.$authMethod; $authObject = new $class(); ... return $authObject; // <-- it returns an object, use it!}
So what you missed is to store the returned object in a variable to use it
$apiAuth = new ApiAuth();$auth = $apiAuth->newAuth($settings);if ($auth->validateAccessToken()) { if ($auth->accessTokenUpdated()) { $accessTokenData = $auth->getAccessTokenData(); }}