Skip to content
Snippets Groups Projects
Commit 7b321a42 authored by pedrambiria's avatar pedrambiria
Browse files

[FIX] google_calendar: send the request URL for the `redirect_uri`


Before this commit: if a different `web.base.url` is set with
`web.base.url.freeze`, during the first synchronization of Google
calendar it will show a mismatch URL error. The problem is that we
send the `redirect_uri` based on the `web.base.url` in the
`_get_authorize_uri` function.

The solution is to use the request root URL instead.

opw-3175539

closes odoo/odoo#113902

Signed-off-by: default avatarArnaud Joset <arj@odoo.com>
parent 83f0f180
Branches
Tags
No related merge requests found
......@@ -17,10 +17,11 @@ class GoogleAuth(http.Controller):
dbname = state.get('d')
service = state.get('s')
url_return = state.get('f')
base_url = request.httprequest.url_root.strip('/')
with registry(dbname).cursor() as cr:
if kw.get('code'):
access_token, refresh_token, ttl = request.env['google.service']._get_google_tokens(kw['code'], service)
access_token, refresh_token, ttl = request.env['google.service'].with_context(base_url=base_url)._get_google_tokens(kw['code'], service)
# LUL TODO only defined in google_calendar
request.env.user._set_auth_tokens(access_token, refresh_token, ttl)
return redirect(url_return)
......
......@@ -98,7 +98,7 @@ class GoogleService(models.AbstractModel):
not be redirected.
"""
get_param = self.env['ir.config_parameter'].sudo().get_param
base_url = get_param('web.base.url', default='http://www.odoo.com?NoBaseUrl')
base_url = self._context.get('base_url') or self.env.user.get_base_url()
client_id = get_param('google_%s_client_id' % (service,), default=False)
client_secret = get_param('google_%s_client_secret' % (service,), default=False)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment