Page 1 of 1

Oauth plugin wrong callback url

PostPosted: Mon May 04, 2020 3:42 pm
by swingman
Hi all,

I'm on 2019.12 NG-Client running on Tomcat 9 Ubuntu trying to authorise my users to send email via their google-based email accounts. I'm using the oauth plugin. Servoy connects to Google, shows the authorisation screen, but then the user clicks to allow, the Google redirects to a URL with one extra level in it:

Code: Select all
https://<mydomain>:8443/<mysolution>/<mysolution>/solutions/<mysolution>/index.html?code=<some_very_long_code>&scope=https://mail.google.com/&https:=&<mydomain>:8443=<mysolution>&solutions=<mysolution>&m=google_oauth_callback


It should be
Code: Select all
https://<mydomain>:8443/<mysolution>/solutions/...

So Tomcat throws an error because the url is not valid.

The code is:

Code: Select all
function authorise_sending_email() {
   plugins.oauth.serviceBuilder(CLIENT_ID)
   .clientSecret(CLIENT_SECRET)
   .deeplink('google_oauth_callback')
   .callback(google_oauth_callback, 30)
   .scope('https://mail.google.com/')
   .build(plugins.oauth.OAuthProviders.GOOGLE);
}


Any idea of where I may have gone wrong?

Re: Oauth plugin wrong callback url

PostPosted: Tue May 05, 2020 9:11 am
by emera
That's weird.
What does
application.getServerURL()
return?

Re: Oauth plugin wrong callback url

PostPosted: Tue May 05, 2020 9:37 am
by emera
Did you set anything for servoy.context.path on the admin page?

Re: Oauth plugin wrong callback url

PostPosted: Wed May 06, 2020 12:29 pm
by swingman
emera wrote:Did you set anything for servoy.context.path on the admin page?


I have left it blank because I could not find out what to put in there.

Re: Oauth plugin wrong callback url

PostPosted: Wed May 06, 2020 1:27 pm
by swingman
emera wrote:That's weird.
What does
application.getServerURL()
return?


Thanks for the leads.
I need to wait until the users have stopped working before I can deploy a version where I get the value of application.getServerURL();

Re: Oauth plugin wrong callback url

PostPosted: Wed May 06, 2020 1:33 pm
by emera
swingman wrote:
emera wrote:Did you set anything for servoy.context.path on the admin page?


I have left it blank because I could not find out what to put in there.


You don't have to put anything in there, we were wondering where does the duplicated path come from..

Re: Oauth plugin wrong callback url

PostPosted: Wed May 06, 2020 3:22 pm
by swingman
application.getServerURL() gives the exact context on the Tomcat server:

Code: Select all
https://<domain>:8443/<solution-name>/


The solution is on:

Code: Select all
https://<domain>:8443/<solution-name>/solutions/<solution-name>

Re: Oauth plugin wrong callback url

PostPosted: Wed May 06, 2020 4:27 pm
by swingman
I renamed my .war file to something different than my solution name and tried authenticating.
Still got the war name twice in the callback url...

Code: Select all
https://<domain>:8443/ANYTHING/ANYTHING/solutions/<solution-name>

Re: Oauth plugin wrong callback url

PostPosted: Thu May 07, 2020 3:09 pm
by jcompagner
we finally found the problem, created a case for it https://support.servoy.com/browse/SVY-14985

it was a redirect problem of deeplink urls (the one that google comes back with, not the one you specify) when having a context in the url

Re: Oauth plugin wrong callback url

PostPosted: Thu May 07, 2020 10:57 pm
by swingman
Hi Johan,

Thanks for locating and fixing this bug.

For anyone else about to embark on switching to oAuth for email authentication;
I followed the Servoy oAuth Youtube video and Patrick's post on this forum.
With this bug out of the way, it will be reasonably simple to implement.

Christian

Re: Oauth plugin wrong callback url

PostPosted: Thu May 07, 2020 10:59 pm
by swingman
Does this mean that that this would work without the fix if I rename my .war to ROOT.war so it deploys on Tomcat without a context?

Christian

Re: Oauth plugin wrong callback url

PostPosted: Fri May 08, 2020 9:55 am
by jcompagner
yes without a context it should work.