Oauth plugin wrong callback url

Discuss all problems you have with Servoy here. It might help to mention the Servoy version and Operating System version you are using

Oauth plugin wrong callback url

Postby swingman » Mon May 04, 2020 3:42 pm

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?
Christian Batchelor
Certified Servoy Developer
Batchelor Associates Ltd, London, UK
http://www.batchelorassociates.co.uk

http://www.postgresql.org - The world's most advanced open source database.
User avatar
swingman
 
Posts: 1301
Joined: Wed Oct 01, 2003 10:20 am
Location: London

Re: Oauth plugin wrong callback url

Postby emera » Tue May 05, 2020 9:11 am

That's weird.
What does
application.getServerURL()
return?
emera
 
Posts: 27
Joined: Tue Jun 17, 2014 8:33 am

Re: Oauth plugin wrong callback url

Postby emera » Tue May 05, 2020 9:37 am

Did you set anything for servoy.context.path on the admin page?
emera
 
Posts: 27
Joined: Tue Jun 17, 2014 8:33 am

Re: Oauth plugin wrong callback url

Postby swingman » Wed May 06, 2020 12:29 pm

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.
Christian Batchelor
Certified Servoy Developer
Batchelor Associates Ltd, London, UK
http://www.batchelorassociates.co.uk

http://www.postgresql.org - The world's most advanced open source database.
User avatar
swingman
 
Posts: 1301
Joined: Wed Oct 01, 2003 10:20 am
Location: London

Re: Oauth plugin wrong callback url

Postby swingman » Wed May 06, 2020 1:27 pm

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();
Christian Batchelor
Certified Servoy Developer
Batchelor Associates Ltd, London, UK
http://www.batchelorassociates.co.uk

http://www.postgresql.org - The world's most advanced open source database.
User avatar
swingman
 
Posts: 1301
Joined: Wed Oct 01, 2003 10:20 am
Location: London

Re: Oauth plugin wrong callback url

Postby emera » Wed May 06, 2020 1:33 pm

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..
emera
 
Posts: 27
Joined: Tue Jun 17, 2014 8:33 am

Re: Oauth plugin wrong callback url

Postby swingman » Wed May 06, 2020 3:22 pm

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>
Christian Batchelor
Certified Servoy Developer
Batchelor Associates Ltd, London, UK
http://www.batchelorassociates.co.uk

http://www.postgresql.org - The world's most advanced open source database.
User avatar
swingman
 
Posts: 1301
Joined: Wed Oct 01, 2003 10:20 am
Location: London

Re: Oauth plugin wrong callback url

Postby swingman » Wed May 06, 2020 4:27 pm

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>
Christian Batchelor
Certified Servoy Developer
Batchelor Associates Ltd, London, UK
http://www.batchelorassociates.co.uk

http://www.postgresql.org - The world's most advanced open source database.
User avatar
swingman
 
Posts: 1301
Joined: Wed Oct 01, 2003 10:20 am
Location: London

Re: Oauth plugin wrong callback url

Postby jcompagner » Thu May 07, 2020 3:09 pm

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
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8284
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Oauth plugin wrong callback url

Postby swingman » Thu May 07, 2020 10:57 pm

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
Christian Batchelor
Certified Servoy Developer
Batchelor Associates Ltd, London, UK
http://www.batchelorassociates.co.uk

http://www.postgresql.org - The world's most advanced open source database.
User avatar
swingman
 
Posts: 1301
Joined: Wed Oct 01, 2003 10:20 am
Location: London

Re: Oauth plugin wrong callback url

Postby swingman » Thu May 07, 2020 10:59 pm

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
Christian Batchelor
Certified Servoy Developer
Batchelor Associates Ltd, London, UK
http://www.batchelorassociates.co.uk

http://www.postgresql.org - The world's most advanced open source database.
User avatar
swingman
 
Posts: 1301
Joined: Wed Oct 01, 2003 10:20 am
Location: London

Re: Oauth plugin wrong callback url

Postby jcompagner » Fri May 08, 2020 9:55 am

yes without a context it should work.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8284
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet


Return to Discuss possible Issues and Bugs

Who is online

Users browsing this forum: No registered users and 2 guests