diff options
| author | Denis Ledoux <dle@openerp.com> | 2013-06-26 16:52:13 +0200 |
|---|---|---|
| committer | Denis Ledoux <dle@openerp.com> | 2013-06-26 16:52:13 +0200 |
| commit | afa6ea8e4f14bb2064e786efd862bfbe3dd3e838 (patch) | |
| tree | 7e02fd2719ea9b12eff201877a9a4265cf765c39 /addons/google_base_account | |
| parent | 66520d9e8e3d62eb4bec66ccd797211d3841c13f (diff) | |
| parent | f694c37b83f23daab9f7f6c86fd01a0184630386 (diff) | |
[IMP]google_drive: cleanup
bzr revid: dle@openerp.com-20130626145213-37to2q3q9jh4lnsg
Diffstat (limited to 'addons/google_base_account')
| -rw-r--r-- | addons/google_base_account/google_base_account.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/addons/google_base_account/google_base_account.py b/addons/google_base_account/google_base_account.py index 39ccc569767..8ee600467b3 100644 --- a/addons/google_base_account/google_base_account.py +++ b/addons/google_base_account/google_base_account.py @@ -22,8 +22,8 @@ from openerp.osv import osv from openerp import SUPERUSER_ID -from httplib2 import Http import urllib +import urllib2 import simplejson @@ -31,7 +31,6 @@ class base_config_settings(osv.osv): _inherit = "base.config.settings" def onchange_google_authorization_code(self, cr, uid, ids, service, authorization_code, context=None): - res = {} if authorization_code: ir_config = self.pool['ir.config_parameter'] client_id = ir_config.get_param(cr, SUPERUSER_ID, 'google_%s_client_id' % service) @@ -39,14 +38,18 @@ class base_config_settings(osv.osv): redirect_uri = ir_config.get_param(cr, SUPERUSER_ID, 'google_redirect_uri') #Get the Refresh Token From Google And store it in ir.config_parameter - headers = {"Content-type": "application/x-www-form-urlencoded"} - data = dict(code=authorization_code, client_id=client_id, client_secret=client_secret, redirect_uri=redirect_uri, grant_type="authorization_code") - data = urllib.urlencode(data) - resp, content = Http().request("https://accounts.google.com/o/oauth2/token", "POST", data, headers) + data = { + 'code': authorization_code, + 'client_id': client_id, + 'client_secret': client_secret, + 'redirect_uri': redirect_uri, + 'grant_type': "authorization_code", + } + resp, content = urllib2.urlopen("https://accounts.google.com/o/oauth2/token", urllib.urlencode(data)) content = simplejson.loads(content) if 'refresh_token' in content.keys(): ir_config.set_param(cr, uid, 'google_%s_refresh_token' % service, content['refresh_token']) - return res + return {} def _get_google_token_uri(self, cr, uid, service, context=None): ir_config = self.pool['ir.config_parameter'] |
