Skip to content

Commit 7885212

Browse files
committed
Revert "Use .us Microsoft endpoints for Office365 OAuth"
This reverts commit 9af8ea3.
1 parent 7f75cfc commit 7885212

1 file changed

Lines changed: 2 additions & 15 deletions

File tree

ProcessMaker/Managers/OauthMailManager.php

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use Illuminate\Mail\MailManager;
1010
use ProcessMaker\Models\EnvironmentVariable;
1111
use ProcessMaker\Packages\Connectors\Email\EmailConfig;
12-
use ProcessMaker\Models\Setting;
1312

1413
class OauthMailManager extends MailManager
1514
{
@@ -128,25 +127,13 @@ private function refreshAccessToken()
128127
{
129128
try {
130129
$index = $this->emailServerIndex ? "_{$this->emailServerIndex}" : '';
131-
//Get Mail Host
132-
$key = "EMAIL_CONNECTOR_MAIL_HOST{$index}";
133-
$settingEmailConnectorMailHost = Setting::byKey($key)?->config ?? null;
134-
135-
$baseUrlMicrosoft = 'https://login.microsoftonline.com/';
136-
$permissions = 'https://outlook.office.com/IMAP.AccessAsUser.All https://outlook.office.com/POP.AccessAsUser.All https://outlook.office.com/SMTP.Send offline_access';
137-
// Change the Microsoft Base Url and scopes according to the environment if the mail host ends with .us, which is the case for Microsoft 365 US Government.
138-
if ($settingEmailConnectorMailHost && is_string($settingEmailConnectorMailHost) && str_ends_with($settingEmailConnectorMailHost, '.us')) {
139-
$baseUrlMicrosoft = 'https://login.microsoftonline.us/';
140-
$permissions = 'https://outlook.office365.us/IMAP.AccessAsUser.All https://outlook.office365.us/POP.AccessAsUser.All https://outlook.office365.us/SMTP.Send offline_access';
141-
}
142-
143130
$guzzle = new Client();
144-
$url = $baseUrlMicrosoft . $this->token->tenant_id . '/oauth2/v2.0/token';
131+
$url = 'https://login.microsoftonline.com/' . $this->token->tenant_id . '/oauth2/v2.0/token';
145132
$newToken = json_decode($guzzle->post($url, [
146133
'form_params' => [
147134
'client_id' => $this->token->client_id,
148135
'client_secret' => $this->token->client_secret,
149-
'scope' => $permissions,
136+
'scope' => 'https://outlook.office.com/IMAP.AccessAsUser.All https://outlook.office.com/POP.AccessAsUser.All https://outlook.office.com/SMTP.Send offline_access',
150137
'refresh_token' => $this->token->refresh_token,
151138
'grant_type' => 'refresh_token',
152139
],

0 commit comments

Comments
 (0)