'This method return the url needed to allow this instance of Odoo to access to the scope
of gmail specified as parameters'

@api.model
def _get_authorize_uri(self, from_url, service, scope=False):

    state = {'d': self.env.cr.dbname, 's': service, 'f': from_url}
    Parameters = self.env['ir.config_parameter']
    base_url = Parameters.get_param('web.base.url', default='http://www.odoo.com?NoBaseUrl')
    client_id = Parameters.sudo().get_param(('google_%s_client_id' % (service,)), default=False)
    encoded_params = werkzeug.url_encode({'response_type': 'code', 'client_id': client_id, 'state': json.dumps(state), 'scope': (scope or ('%s/auth/%s' % (GOOGLE_API_BASE_URL, service))), 'redirect_uri': (base_url + '/google_account/authentication'), 'approval_prompt': 'force', 'access_type': 'offline'})
    return ('%s?%s' % (GOOGLE_AUTH_ENDPOINT, encoded_params))
