As far as I understood from the release notes, the 2.3.0 version allows Basic Authentication on the Mautic API. That’s good news for me, but… not sure how to make it work.
My Mautic installation upgraded to 2.3.0 … done!
Enabled HTTP basic auth on “API Configuration” … done!
New API credentials created… well…
There it starts. I couldn’t find a way to create credentials for the basic auth. If I try to run a “curl” command on the terminal, the response says:
{“error”:“access_denied”,“error_description”:“OAuth2 authentication required”}
Could anyone help me out with that?
And just to avoid any misunderstanding, does “HTTP basic auth” mean that I can make this call:
$ curl -u username:password https://www.mautic-example.com/api/resources
and it will work?
As far as I understood from the release notes, the 2.3.0 version allows Basic Authentication on the Mautic API. That’s good news for me, but… not sure how to make it work.
My Mautic installation upgraded to 2.3.0 … done!
Enabled HTTP basic auth on “API Configuration” … done!
New API credentials created… well…
There it starts. I couldn’t find a way to create credentials for the basic auth. If I try to run a “curl” command on the terminal, the response says:
{“error”:“access_denied”,“error_description”:“OAuth2 authentication required”}
Could anyone help me out with that?
And just to avoid any misunderstanding, does “HTTP basic auth” mean that I can make this call:
$ curl -u username:password https://www.mautic-example.com/api/resources
and it will work?
Answering myself: yes, the curl command above will work, but:
- the correct command form would be
curl -H "Authorization: Basic ##########" https://www.mautic-example.com/api/contacts
- “###########” is a Base64 representation of the string “:”, where and can be your very login data for the Mautic application. The Base64 string can be generated on a Linux command line, e.g.
$ echo "myuser:12345" | base64
The Base64 trick is mentioned on the documentation, but either I missed it entirely or it was added later. Whatever…
I was having the same problem. Thanks @rnogueir for the format. A couple things I ran into:
It seems that an incorrect username and password will also trigger the error:
{"error":"access_denied","error_description":"OAuth2 authentication required"}
Make sure you use -n with “echo” to prevent adding a newline to the encoding. This will render your username and password incorrect and you will get the same error as above. Like this works:
$ echo -n "myuser:12345" | base64