Mautic Community Forums

Api call example ?

Hello,



I have installed Mautic on my own server. Everything works well ! Thanks a lot.



Now, i want to connect my application (Node JS / Express) to Mautic by the API.

There are different libraries from NPM to connect the oauth2 protocol.

I’m ready to use this one : simple-oauth2

There are 3 strategies : Authorization Code flow,Password Credentials Flow,Client Credentials Flow.

=> What’s the good one ? Authorization Code flow right ?




I didn’t succeed, i’m getting always a bad message about authorization from mautic.



=> Can somebody send me an example of the OAUTH2 HTTP call ?

I just want an example about the url and parameters…


Edit !

https://github.com/mautic/developer-documentation/blob/master/source/includes/_api_authorization_oauth2.md

https://developer.mautic.org/#oauth-2



My last try with a simple http request :

http://[MY MAUTIC]/oauth/v2/authorize?grant_type=authorization_code&response_type=code&client_id=1_59og0q5y684kss048swko408sgo0w4gssskc0goko48o84gscg&state=TESTNUMBER1&redirect_uri=http://[MY MAUTIC]



=> redirect to /oauth/v2/authorize_login (302 & 200)

=> i don’t see any callback in the access logs of my app




Edit !

=> It work’s… i just need to login with my personnal account.

I dont understand how it works… how my app can deal with this login page ?




http://[MY MAUTIC]/oauth/v2/token?code=[GET FROM CALLBACK ?]&grant_type=authorization_code&client_id=1_59og0q5y684kss048swko408sgo0w4gssskc0goko48o84gscg&client_secret=1csq0ylkc3dw0w0004os8ssos4wg0k0okgsoo08ksc80s4kgk4&redirect_uri=http://[MY MAUTIC]



=> OK, i’m getting the token



I have checked the api-lib and forums about Mautic Api and FOS Bundle Oauth and noooo way



Edit !

Api details here :


=> https://developer.mautic.org/#create-lead



endpoint here is wrong ? “leads/edit/{id}” ??



Merci beaucoup for your help,

Merry christmas !

Hello,

I have installed Mautic on my own server. Everything works well ! Thanks a lot.

Now, i want to connect my application (Node JS / Express) to Mautic by the API.
There are different libraries from NPM to connect the oauth2 protocol.
I’m ready to use this one : simple-oauth2
There are 3 strategies : Authorization Code flow,Password Credentials Flow,Client Credentials Flow.
=> What’s the good one ? Authorization Code flow right ?

I didn’t succeed, i’m getting always a bad message about authorization from mautic.

=> Can somebody send me an example of the OAUTH2 HTTP call ?
I just want an example about the url and parameters…

Edit !
https://github.com/mautic/developer-documentation/blob/master/source/includes/_api_authorization_oauth2.md
https://developer.mautic.org/#oauth-2

My last try with a simple http request :
http://[MY MAUTIC]/oauth/v2/authorize?grant_type=authorization_code&response_type=code&client_id=1_59og0q5y684kss048swko408sgo0w4gssskc0goko48o84gscg&state=TESTNUMBER1&redirect_uri=http://[MY MAUTIC]

=> redirect to /oauth/v2/authorize_login (302 & 200)
=> i don’t see any callback in the access logs of my app

Edit !
=> It work’s… i just need to login with my personnal account.
I dont understand how it works… how my app can deal with this login page ?

http://[MY MAUTIC]/oauth/v2/token?code=[GET FROM CALLBACK ?]&grant_type=authorization_code&client_id=1_59og0q5y684kss048swko408sgo0w4gssskc0goko48o84gscg&client_secret=1csq0ylkc3dw0w0004os8ssos4wg0k0okgsoo08ksc80s4kgk4&redirect_uri=http://[MY MAUTIC]

=> OK, i’m getting the token

I have checked the api-lib and forums about Mautic Api and FOS Bundle Oauth and noooo way

Edit !
Api details here :

=> https://developer.mautic.org/#create-lead

endpoint here is wrong ? “leads/edit/{id}” ??

Merci beaucoup for your help,
Merry christmas !

Wow, you did great! Thanks for the updates of your work. The most effective way how to get the possible endpoints is to look at the code directly. LeadBundle’s API routes are here:

https://github.com/mautic/mautic/blob/staging/app/bundles/LeadBundle/Config/config.php#L59-L128

To answer your last question, the right endpoint is /leads/{id}/edit

I’m trying to connect Zapier with Mautic, I’ve install github API so now there’s /lib folder in my root directory, but zapier can’t connect it gets HTTP 403 error http://MyWebSiteExample.com/oauth/v2/authorize?response_type=

There’s no /oauth/ folder in my install or the api library I installed???

As a troubleshooting test I was able to go to mautic.net setup a test account and connect zapier to it there, I see it going to the /oauth/ path at mautic.net no problem and authorization happens as expected, but with my self hosted install, I’m getting this 403 error?

I tried going to the apitester/ folder to see if I could test my api is working but I just get and error, I’ve seen screen shoots of the tester, but I can’t access it to test mautic api either
when I browse to apitester I get {“error”:“access_denied”,“error_description”:“OAuth2 authentication required”}