(self, authorize_code, service)
Call Microsoft API to exchange authorization code against token, with POST request, to
            not be redirected.
Call Microsoft API to exchange authorization code against token, with POST request, to
            not be redirected.
Call Microsoft API to exchange authorization code against token with POST request to not be redirected .
def _get_microsoft_tokens(self, authorize_code, service):
        """ Call Microsoft API to exchange authorization code against token, with POST request, to
            not be redirected.
        """
        get_param = self.env['ir.config_parameter'].sudo().get_param
        base_url = get_param('web.base.url', default='http://www.odoo.com?NoBaseUrl')
        client_id = get_param('microsoft_%s_client_id' % (service,), default=False)
        client_secret = get_param('microsoft_%s_client_secret' % (service,), default=False)
        scope = self._get_calendar_scope()

        headers = {"content-type": "application/x-www-form-urlencoded"}
        data = {
            'code': authorize_code,
            'client_id': client_id,
            'client_secret': client_secret,
            'grant_type': 'authorization_code',
            'scope': scope,
            'redirect_uri': base_url + '/microsoft_account/authentication'
        }
        try:
            dummy, response, dummy = self._do_request(self._get_token_endpoint(), params=data, headers=headers, method='POST', preuri='')
            access_token = response.get('access_token')
            refresh_token = response.get('refresh_token')
            ttl = response.get('expires_in')
            return access_token, refresh_token, ttl
        except requests.HTTPError:
            error_msg = _("Something went wrong during your token generation. Maybe your Authorization Code is invalid")
            raise self.env['res.config.settings'].get_config_warning(error_msg)
def _get_microsoft_tokens ( self , authorize_code , service ) : get_param = self . env [ 'ir.config_parameter' ] . sudo ( ) . get_param base_url = get_param ( 'web.base.url' , default = 'http://www.odoo.com?NoBaseUrl' ) client_id = get_param ( 'microsoft_%s_client_id' % ( service , ) , default = False ) client_secret = get_param ( 'microsoft_%s_client_secret' % ( service , ) , default = False ) scope = self . _get_calendar_scope ( ) headers = { "content-type" : "application/x-www-form-urlencoded" } data = { 'code' : authorize_code , 'client_id' : client_id , 'client_secret' : client_secret , 'grant_type' : 'authorization_code' , 'scope' : scope , 'redirect_uri' : base_url + '/microsoft_account/authentication' } try : dummy , response , dummy = self . _do_request ( self . _get_token_endpoint ( ) , params = data , headers = headers , method = 'POST' , preuri = '' ) access_token = response . get ( 'access_token' ) refresh_token = response . get ( 'refresh_token' ) ttl = response . get ( 'expires_in' ) return access_token , refresh_token , ttl except requests . HTTPError : error_msg = _ ( "Something went wrong during your token generation. Maybe your Authorization Code is invalid" ) raise self . env [ 'res.config.settings' ] . get_config_warning ( error_msg )