mautic / mautic/api-library

I get Class 'Mautic\\Auth\\ApiAuth' not found since updated

Open
#266 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
205
Forks
129
PR merge metrics
No merged PRs in 30d

Description

Since we updated to the current Mautic Version 4.2.0 I get this error:

Uncaught Error: Class 'Mautic\\Auth\\ApiAuth' not found

I created a new server from the scratch and I get the same error. We did this conector, which worked fine until now:

<?php
  include 'vendor/autoload.php';
  use Mautic\Auth\ApiAuth;
  use Mautic\MauticApi;
//define function name  

  session_start();

  $settings = array(
      'userName'         => 'user',
      'password'         => 'pass',
  );

  $initAuth   = new ApiAuth();
  $auth       = $initAuth->newAuth($settings, 'BasicAuth');

  try{
    if ($auth) {
      $api        = new MauticApi();
      $contactApi = $api->newApi("contacts", $auth, 'https://mautic/api/');
      file_put_contents('conector.log', 'REQUEST: '.print_r($_REQUEST,true),FILE_APPEND);
            if($_REQUEST['action'] == "new"){
                $firstname = $_REQUEST['firstname'];
                $lastname = $_REQUEST['lastname'];
                $email = $_REQUEST['email'];
                $company = $_REQUEST['company'];
                $country = $_REQUEST['country'];
                $preferred_locale = strtolower($_REQUEST['preferred_locale']);
                $birthdate = $_REQUEST['birthdate'];
                $gender = $_REQUEST['gender'];
                $crm_source = $_REQUEST['crm_source'];

       $data = array(
        'firstname'     =>      $firstname,
        'lastname'      =>      $lastname,
        'email'     =>  $email,
        'company'       =>      $company,
        'country'       =>      $country,
        'preferred_locale'      =>      $preferred_locale,
        'birthdate'      =>      $birthdate,
        'gender'        =>      $gender,
        'crm_source'    =>      $crm_source
        );


        $contact = $contactApi->create($data);

        file_put_contents('conector.log', 'CONTACT API '.print_r($contact,true),FILE_APPEND | LOCK_EX);
        $idcontacto = $contact['contact']['id'];
 }else if($_REQUEST['action'] == "delete"){
        $contact = $contactApi->delete($_REQUEST['idContact']);
      }

    } else {
                echo "Error!";
    }
  } catch (Exception $e) {
        echo "Mautic not connected!";
  }
?>


<bountysource-plugin>

---
Want to back this issue? **[Post a bounty on it!](https://app.bountysource.com/issues/108499070-i-get-class-mautic-auth-apiauth-not-found-since-updated?utm_campaign=plugin&utm_content=tracker%2F10940535&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://app.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F10940535&utm_medium=issues&utm_source=github).
</bountysource-plugin>

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the supplied PHP connector and its vendor/autoload.php include, then reproduce the missing Mautic\Auth\ApiAuth error against Mautic 4.2.0. Check how the API library exposes authentication and compare that with the connector's ApiAuth and MauticApi usage. Done means the connector's authentication path works on a fresh setup or the incompatibility is clearly documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.