Mautic Community Forums

OAuth2 Redirect URI?

Hi everyone,





I’ll get straight to the point. I read this here: https://developer.mautic.org/#oauth-2



It is my understanding that after the first step of OAuth2, Mautic redirects the user to the redirect URI while adding two GET variables - the code and the state - so it looks like this:



https://your-redirect-uri.com?code=UNIQUE_CODE_STRING&state=UNIQUE_STATE_STRING





So far so good. Now, my question is the following:



How do I handle this if I already have a question mark (GET variables) in my Redirect URI?



We all know that an URI with more than one question mark will not work. So, what would you recommend if my Redirect URI looked like this?



http://your-redirect-uri.com/index.php?module=Mautic&parent=Settings&view=Edit



There is no way that this is going to work after Mautic appends this to it:



?code=UNIQUE_CODE_STRING&state=UNIQUE_STATE_STRING



so that is ends up looking like this:



http://your-redirect-uri.com/index.php?module=Mautic&parent=Settings&view=Edit?code=UNIQUE_CODE_STRING&state=UNIQUE_STATE_STRING



This has two question marks in it, and it’s clearly going to fail.



So, what would you recommend? Should I try to get a Redirect URI which doesn’t already receive GET variables? Or does anyone have any better ideas?



Thanks.



SomethingOrOther



P.S. I did manage to build a small PHP script without these GET variables and it was able to successfully authorize into Mautic and query the contacts. So I understand how the whole process works, but I don’t know what should be done if the Redirect URI already has to have GET variables by design.

Hi everyone,

I’ll get straight to the point. I read this here: https://developer.mautic.org/#oauth-2

It is my understanding that after the first step of OAuth2, Mautic redirects the user to the redirect URI while adding two GET variables - the code and the state - so it looks like this:

https://your-redirect-uri.com?code=UNIQUE_CODE_STRING&state=UNIQUE_STATE_STRING

So far so good. Now, my question is the following:

How do I handle this if I already have a question mark (GET variables) in my Redirect URI?

We all know that an URI with more than one question mark will not work. So, what would you recommend if my Redirect URI looked like this?

http://your-redirect-uri.com/index.php?module=Mautic&parent=Settings&view=Edit

There is no way that this is going to work after Mautic appends this to it:

?code=UNIQUE_CODE_STRING&state=UNIQUE_STATE_STRING

so that is ends up looking like this:

http://your-redirect-uri.com/index.php?module=Mautic&parent=Settings&view=Edit?code=UNIQUE_CODE_STRING&state=UNIQUE_STATE_STRING

This has two question marks in it, and it’s clearly going to fail.

So, what would you recommend? Should I try to get a Redirect URI which doesn’t already receive GET variables? Or does anyone have any better ideas?

Thanks.

SomethingOrOther

P.S. I did manage to build a small PHP script without these GET variables and it was able to successfully authorize into Mautic and query the contacts. So I understand how the whole process works, but I don’t know what should be done if the Redirect URI already has to have GET variables by design.

You should be able to replace the ? with an & so that you concatenate the two sets of variable.s.