Skip to content
Snippets Groups Projects
Commit 3f651ead authored by Archana Vaghasiya's avatar Archana Vaghasiya
Browse files

[FIX] google_account: accessing the url without any post data


When a user tries to access the URL directly, at that time the value of
dictionary `kw` is not available. The error will be generated.

Error : KeyError: 'state'

This commit will prevent the traceback.

sentry-3947033806

closes odoo/odoo#126346

X-original-commit: dfc1a188
Signed-off-by: default avatarAchraf Ben Azzouz (abz) <abz@odoo.com>
parent 923c2d69
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import json
from werkzeug.exceptions import BadRequest
from odoo import http
from odoo.http import request
......@@ -12,11 +13,13 @@ class GoogleAuth(http.Controller):
@http.route('/google_account/authentication', type='http', auth="public")
def oauth2callback(self, **kw):
""" This route/function is called by Google when user Accept/Refuse the consent of Google """
state = json.loads(kw['state'])
state = json.loads(kw.get('state', '{}'))
dbname = state.get('d')
service = state.get('s')
url_return = state.get('f')
base_url = request.httprequest.url_root.strip('/')
if (not dbname or not service or (kw.get('code') and not url_return)):
raise BadRequest()
if kw.get('code'):
access_token, refresh_token, ttl = request.env['google.service'].with_context(base_url=base_url)._get_google_tokens(kw['code'], service)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment