Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mautic Basic Authentication Through Rest Api

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?

like image 589
Muhammad Wasim Shahzad Avatar asked Jan 31 '17 09:01

Muhammad Wasim Shahzad


1 Answers

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

like image 129
John Linhart Avatar answered Sep 30 '22 20:09

John Linhart