|
9 | 9 | use Illuminate\Mail\MailManager; |
10 | 10 | use ProcessMaker\Models\EnvironmentVariable; |
11 | 11 | use ProcessMaker\Packages\Connectors\Email\EmailConfig; |
12 | | -use ProcessMaker\Models\Setting; |
13 | 12 |
|
14 | 13 | class OauthMailManager extends MailManager |
15 | 14 | { |
@@ -128,25 +127,13 @@ private function refreshAccessToken() |
128 | 127 | { |
129 | 128 | try { |
130 | 129 | $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 | | - |
143 | 130 | $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'; |
145 | 132 | $newToken = json_decode($guzzle->post($url, [ |
146 | 133 | 'form_params' => [ |
147 | 134 | 'client_id' => $this->token->client_id, |
148 | 135 | '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', |
150 | 137 | 'refresh_token' => $this->token->refresh_token, |
151 | 138 | 'grant_type' => 'refresh_token', |
152 | 139 | ], |
|
0 commit comments