tenant($connection).'/oauth2/v2.0/authorize?'.http_build_query([ 'client_id' => (string) $connection->client_id, 'response_type' => 'code', 'redirect_uri' => $redirectUri, 'response_mode' => 'query', 'scope' => self::SCOPE, 'state' => $state, 'prompt' => 'select_account', ]); } protected function tokenEndpoint(MailOAuthConnection $connection): string { return 'https://login.microsoftonline.com/'.$this->tenant($connection).'/oauth2/v2.0/token'; } protected function scope(): string { return self::SCOPE; } /** * Blank falls back to 'common', which admits work/school accounts of * any tenant plus personal accounts — the inclusive default for this * app's audience. 'consumers' and 'organizations' work here too; a * Consumer-audience app registration in fact requires 'consumers', * as /common refuses that userAudience outright. */ private function tenant(MailOAuthConnection $connection): string { $tenant = $connection->tenant_id; return is_string($tenant) && trim($tenant) !== '' ? trim($tenant) : 'common'; } }