# Oauth plugin wrong callback url

**URL:** <https://forum.servoy.com/t/oauth-plugin-wrong-callback-url/20231>\
**Category:** Feedback\
**Created:** [May 4, 2020, 1:42pm UTC](https://forum.servoy.com/t/oauth-plugin-wrong-callback-url/20231 "2020-05-04T13:42:35Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![swingman](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/swingman/32/4536_2.png) [@swingman](https://forum.servoy.com/u/swingman)\
**Post date:** [May 4, 2020, 1:42pm UTC](https://forum.servoy.com/t/oauth-plugin-wrong-callback-url/20231/1 "2020-05-04T13:42:35Z")

</div>

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:

```auto
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

```auto
https://<mydomain>:8443/<mysolution>/solutions/...

```

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

The code is:

```auto
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?

---

<div class="post-metadata">

**Author:** ![emera](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@emera](https://forum.servoy.com/u/emera)\
**Post date:** [May 5, 2020, 7:11am UTC](https://forum.servoy.com/t/oauth-plugin-wrong-callback-url/20231/2 "2020-05-05T07:11:54Z")

</div>

That’s weird.  
What does  
application.getServerURL()  
return?

---

<div class="post-metadata">

**Author:** ![emera](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@emera](https://forum.servoy.com/u/emera)\
**Post date:** [May 5, 2020, 7:37am UTC](https://forum.servoy.com/t/oauth-plugin-wrong-callback-url/20231/3 "2020-05-05T07:37:30Z")

</div>

Did you set anything for servoy.context.path on the admin page?

---

<div class="post-metadata">

**Author:** ![swingman](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/swingman/32/4536_2.png) [@swingman](https://forum.servoy.com/u/swingman)\
**Post date:** [May 6, 2020, 10:29am UTC](https://forum.servoy.com/t/oauth-plugin-wrong-callback-url/20231/4 "2020-05-06T10:29:58Z")

</div>

> emera:  
> 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.

---

<div class="post-metadata">

**Author:** ![swingman](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/swingman/32/4536_2.png) [@swingman](https://forum.servoy.com/u/swingman)\
**Post date:** [May 6, 2020, 11:27am UTC](https://forum.servoy.com/t/oauth-plugin-wrong-callback-url/20231/5 "2020-05-06T11:27:34Z")

</div>

> emera:  
> 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();

---

<div class="post-metadata">

**Author:** ![emera](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@emera](https://forum.servoy.com/u/emera)\
**Post date:** [May 6, 2020, 11:33am UTC](https://forum.servoy.com/t/oauth-plugin-wrong-callback-url/20231/6 "2020-05-06T11:33:41Z")

</div>

> swingman:
> 
> > emera:  
> > 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…

---

<div class="post-metadata">

**Author:** ![swingman](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/swingman/32/4536_2.png) [@swingman](https://forum.servoy.com/u/swingman)\
**Post date:** [May 6, 2020, 1:22pm UTC](https://forum.servoy.com/t/oauth-plugin-wrong-callback-url/20231/7 "2020-05-06T13:22:46Z")

</div>

application.getServerURL() gives the exact context on the Tomcat server:

```auto
https://<domain>:8443/<solution-name>/

```

The solution is on:

```auto
https://<domain>:8443/<solution-name>/solutions/<solution-name>

```

---

<div class="post-metadata">

**Author:** ![swingman](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/swingman/32/4536_2.png) [@swingman](https://forum.servoy.com/u/swingman)\
**Post date:** [May 6, 2020, 2:27pm UTC](https://forum.servoy.com/t/oauth-plugin-wrong-callback-url/20231/8 "2020-05-06T14:27:44Z")

</div>

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…

```auto
https://<domain>:8443/ANYTHING/ANYTHING/solutions/<solution-name>

```

---

<div class="post-metadata">

**Author:** ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)\
**Post date:** [May 7, 2020, 1:09pm UTC](https://forum.servoy.com/t/oauth-plugin-wrong-callback-url/20231/9 "2020-05-07T13:09:10Z")

</div>

we finally found the problem, created a case for it [https://support.servoy.com/browse/SVY-14985](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

---

<div class="post-metadata">

**Author:** ![swingman](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/swingman/32/4536_2.png) [@swingman](https://forum.servoy.com/u/swingman)\
**Post date:** [May 7, 2020, 8:57pm UTC](https://forum.servoy.com/t/oauth-plugin-wrong-callback-url/20231/10 "2020-05-07T20:57:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![swingman](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/swingman/32/4536_2.png) [@swingman](https://forum.servoy.com/u/swingman)\
**Post date:** [May 7, 2020, 8:59pm UTC](https://forum.servoy.com/t/oauth-plugin-wrong-callback-url/20231/11 "2020-05-07T20:59:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)\
**Post date:** [May 8, 2020, 7:55am UTC](https://forum.servoy.com/t/oauth-plugin-wrong-callback-url/20231/12 "2020-05-08T07:55:20Z")

</div>

yes without a context it should work.
