6

As per mautic developer documentation,I am connecting to mautic basic authorization through custom php using curl locally but it is redirecting me to mautic login page but in my view this is not the correct response.......I want to know whats the correct response of this basic authorization?



    $login = 'admin';
    $password = '123456';
    $url = 'http://127.0.0.1/mautic/'; //localhost
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,$url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    curl_setopt($ch, CURLOPT_HTTPHEADER,
        array(
            "Authorization: Basic " . base64_encode($login . ":" . $password)
        ));

    $status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $result = curl_exec($ch);
    print_r(curl_exec($ch));
    curl_close($ch);

Also i want to know is Basic Authentication in Mautic different from Oauth2 authorization?

  • 3
    After researching and using hit and try method i got the basic authentication working .... **Mautic** does not give success or failure message instead of it you have to use the full basepoint url of specific data which you need..... e.g if you need data of contacts in mautic use this endpoint with authorization header of your credential..... `http://your-address/mautic/api/contacts` (in my case your-address=localhost) – Muhammad Wasim Shahzad Feb 20 '17 at 07:27

1 Answers1

1

For the reference, here is the Mautic API Basic Auth docs:

https://developer.mautic.org/?php#basic-authentication

And here is how to use it with the PHP Mautic API Library:

https://github.com/mautic/api-library#using-basic-authentication-instead

John Linhart
  • 1,746
  • 19
  • 23
  • 1
    Can you give me example of basic authentication......?? I have read the documentation but basic authentication is only working when you are using custom request rather than using above basic authentication library... If it possible can you give sample working code of Oauth2 authentication ?? – Muhammad Wasim Shahzad Feb 22 '17 at 10:56