The problem might be that I dont have the experience/understanding of OAuth2 or I’m just having a rough time following the available instructions; likely both. Im trying to get the Mautic API configured so that I can read/write lead information as needed.
With that script, It appears to be a PHP error relating to a problem with this line in the script: use MauticAuthApiAuth; not being processed properly and causing this line: $auth = ApiAuth::initiate($settings); to fail and produce the error message on the server log.
Please let me know if I understood and was able to answer your question properly.
The problem might be that I dont have the experience/understanding of OAuth2 or I’m just having a rough time following the available instructions; likely both. Im trying to get the Mautic API configured so that I can read/write lead information as needed.
My environment:
Mautic v1.4.0
Server-based install on LAMP stack
Client Secret: clientsecret123
~3. Downloaded a .zip of the API library from github and extracted
~4. Uploaded the contents of “lib” folder to /path/to/Mautic/lib/
~5. Created a file with the code to obtain an access token, as instructed via instruction source A, and saved to /path/to/Mautic/apiinit.php
~6. Uploaded the contents of “apitester” folder to /path/to/Mautic/apitester/
Results:
Navigating to the file from step ~5 above results in (with and without hardcoding values for the $settings array) :
A server 500 error in the browser
The following error in my server log: PHP Fatal error: Class ‘Mautic\Auth\ApiAuth’ not found in /path/to/Mautic/apiinit.php on line 28
Line 28: $auth = ApiAuth::initiate($settings);
Navigating the the apitester results in the following message displayed in the browser (the expected form is not displayed at any point):
{“error”:“access_denied”,“error_description”:“OAuth2 authentication required”}
Questions:
~1. Have I placed the contents of the “lib” and “apitester” folders in the right place on my server and, if not, where do these go?
~2. Instruction source C, under Libraries -> PHP Library, says to add the following line to the project, but doesnt specify exactly where:
require_once DIR . ‘/lib/Mautic/MauticApi.php’; //Which folder/file/line does this code get added to?
~3. How do I resolve the two Result issues?
~4. What else might I be missing or getting wrong?
Sorry for the long message and thanks in advance for any help.
I tried using the API with Mautic and finally got it working…
…but felt like I had to hack my way through. I ran the API tester and snatched the token to be used in my php backend application.
The authorization is useless from a backend system because there is no one there to fill in the authorization form!
I wanted to do things like… if a user registers an account on my site, I want to add them as a lead in mautic. This seems fairly simple…but I can’t do that without an authorization token. (again, unless I am missing something).
Im still unclear as to how to do this “properly” without having to use the API tester and grabbing the token generated.
I know this HAS to be possible without an authorization token. (one-legged OAuth?)
The new version of Mautic requires php 7 which is not running on my server and I cannot rebuild an entire box just to use Mautic…
So… I have to run another server simply for running Mautic.
Ill do a clean install (I updated my last installation and nothing worked and lost 17k leads I had created because I was running php 5.4). They are still in my database if I could figure out how to migrate…or this will be a complete loss.
Soooo…giving this another shot. I love what the Mautic guys are doing, I just really really would like to find a really simple solution for talking to Mautic without the need for a popup authorization form. That makes no sense to me unless I am making an administration system and a human is authorizing.
If I am missing something please please please let me know, this would be fantastic to have working with a simple API call.
Well I “had” it working until the 2.0 update. Now I am getting token_rejected errors and can’t seem to get past it. Im using the API on a server for an iPhone app. The app calls the server, and I wanted to communicate to Mautic to update a lead etc.
I created the OAuth1a tokens successfully, after much hacking, and now I am getting token_rejected.
Wish I could help you, but this is the most difficult API experience I have ever come across.
I have struggled to get the api setup with basic auth for OVER A YEAR and this comment fixed my issue finally! I wish there was something I could do to promote this comment to the highest level. Thank you @peyman! I can now move on with my life!