|
@ -81,15 +81,24 @@ class ResConfigSettings(models.TransientModel): |
|
|
tenant_id = self.env['ir.config_parameter'].get_param( |
|
|
tenant_id = self.env['ir.config_parameter'].get_param( |
|
|
'onedrive_integration_odoo.tenant_id', '') |
|
|
'onedrive_integration_odoo.tenant_id', '') |
|
|
res = requests.post( |
|
|
res = requests.post( |
|
|
f"https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token", |
|
|
f"https://login.microsoftonline.com/common/oauth2/v2.0/token", |
|
|
data=data, |
|
|
data=data, |
|
|
headers={"content-type": "application/x-www-form-urlencoded"}) |
|
|
headers={"content-type": "application/x-www-form-urlencoded"}) |
|
|
response = res.content and res.json() or {} |
|
|
response = res.content and res.json() or {} |
|
|
|
|
|
|
|
|
|
|
|
if 'error' in response: |
|
|
|
|
|
res = requests.post( |
|
|
|
|
|
f"https://login.microsoftonline.com/consumers/oauth2/v2.0/token", |
|
|
|
|
|
data=data, |
|
|
|
|
|
headers={"content-type": "application/x-www-form-urlencoded"}) |
|
|
|
|
|
response = res.content and res.json() or {} |
|
|
|
|
|
|
|
|
if 'error' in response: |
|
|
if 'error' in response: |
|
|
raise UserError(_("Error '%s': Please check the credentials.", |
|
|
raise UserError(_("Error '%s': Please check the credentials.", |
|
|
response['error'])) |
|
|
response['error'])) |
|
|
else: |
|
|
|
|
|
authority = 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize' |
|
|
|
|
|
|
|
|
authority = f'https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/authorize' |
|
|
action = self.env["ir.actions.client"].sudo()._for_xml_id( |
|
|
action = self.env["ir.actions.client"].sudo()._for_xml_id( |
|
|
"onedrive_integration_odoo.onedrive_dashboard_action") |
|
|
"onedrive_integration_odoo.onedrive_dashboard_action") |
|
|
base_url = request.env['ir.config_parameter'].get_param( |
|
|
base_url = request.env['ir.config_parameter'].get_param( |
|
|