From f75cbfbe8b4c29145be1d2bda08f2b8e589dc637 Mon Sep 17 00:00:00 2001 From: pedrambiria Date: Mon, 30 Jan 2023 12:48:50 +0000 Subject: [PATCH] [FIX] google_calendar: use the request root 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-3101741 closes odoo/odoo#113215 X-original-commit: 6d713e69e6f412c05fe2af81fb263e09713b4821 Signed-off-by: Arnaud Joset Signed-off-by: Pedram Bi Ria (pebr) --- addons/google_calendar/controllers/main.py | 3 ++- addons/google_calendar/utils/google_calendar.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/google_calendar/controllers/main.py b/addons/google_calendar/controllers/main.py index 40c8b736ab9..adc6bb90e64 100644 --- a/addons/google_calendar/controllers/main.py +++ b/addons/google_calendar/controllers/main.py @@ -18,7 +18,8 @@ class GoogleCalendarController(http.Controller): this URL for authorization for example """ if model == 'calendar.event': - GoogleCal = GoogleCalendarService(request.env['google.service']) + base_url = request.httprequest.url_root.strip('/') + GoogleCal = GoogleCalendarService(request.env['google.service'].with_context(base_url=base_url)) # Checking that admin have already configured Google API for google synchronization ! client_id = request.env['google.service']._get_client_id('calendar') diff --git a/addons/google_calendar/utils/google_calendar.py b/addons/google_calendar/utils/google_calendar.py index 3da73fc1b9a..a2bf89bd32d 100644 --- a/addons/google_calendar/utils/google_calendar.py +++ b/addons/google_calendar/utils/google_calendar.py @@ -112,10 +112,11 @@ class GoogleCalendarService(): 's': 'calendar', 'f': from_url } + base_url = self.google_service._context.get('base_url') or self.google_service.get_base_url() return self.google_service._get_authorize_uri( 'calendar', self._get_calendar_scope(), - self.google_service.get_base_url() + '/google_account/authentication', + base_url + '/google_account/authentication', state=json.dumps(state), approval_prompt='force', access_type='offline'