From e23222151439aa7a307776ec078877a5967a6c56 Mon Sep 17 00:00:00 2001 From: rossasa Date: Wed, 8 Jul 2015 17:32:47 -0400 Subject: [PATCH] [FIX] auth_oauth: login with Facebook Configuration: - Change the scope to: user_profile,email - Change the validation url to 'https://graph.facebook.com/me' that returns more information about the user. Facebook open graph API does not send the expected 'user_id' parameter, need to use the 'id' key. Fixes #5546 Closes #7532 --- addons/auth_oauth/auth_oauth_data.xml | 4 ++-- addons/auth_oauth/res_users.py | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/addons/auth_oauth/auth_oauth_data.xml b/addons/auth_oauth/auth_oauth_data.xml index fe64f42b2f6..b389386f1c1 100644 --- a/addons/auth_oauth/auth_oauth_data.xml +++ b/addons/auth_oauth/auth_oauth_data.xml @@ -14,8 +14,8 @@ Facebook Graph https://www.facebook.com/dialog/oauth - - https://graph.facebook.com/me/permissions + public_profile,email + https://graph.facebook.com/me fa fa-facebook-square Log in with facebook diff --git a/addons/auth_oauth/res_users.py b/addons/auth_oauth/res_users.py index f2c6be389f1..cada7d51a26 100644 --- a/addons/auth_oauth/res_users.py +++ b/addons/auth_oauth/res_users.py @@ -101,7 +101,12 @@ class res_users(osv.Model): validation = self._auth_oauth_validate(cr, uid, provider, access_token) # required check if not validation.get('user_id'): - raise openerp.exceptions.AccessDenied() + # Workaround: facebook does not send 'user_id' in Open Graph Api + if validation.get('id'): + validation['user_id'] = validation['id'] + else: + raise openerp.exceptions.AccessDenied() + # retrieve and sign in user login = self._auth_oauth_signin(cr, uid, provider, validation, params, context=context) if not login: