Open
Description
I am trying to connect to Microsoft Outlook / Exchange
to Microsoft Outlook / Exchange.
I am already getting an access token back.
Unfortunately, I always get the message "connection setup failed"
The error is thrown in the "authenticate" function.
$settings = [
'client_id' => '',
'client_secret' => '',
'tenant_id' => '',
'email' => ''
];
curl_setopt($ch, CURLOPT_URL, 'https://login.microsoftonline.com/' . $settings['tenant_id'] . '/oauth2/v2.0/token');
curl_setopt(
$ch,
CURLOPT_POSTFIELDS,
http_build_query([
'client_id' => $settings['client_id'],
'client_secret' => $settings['client_secret'],
'scope' => 'https://outlook.office365.com/.default',
'grant_type' => 'client_credentials'
])
);
$mails = [];
$cm = new ClientManager();
$client = $cm->make([
'host' => 'outlook.office365.com',
'port' => 993,
'encryption' => 'tls', //ssl
'validate_cert' => true,
'username' => $settings['email'],
'password' => $access_token,
'protocol' => 'imap',
'authentication' => 'oauth'
]);
These are some parts of the code, unfortunately I could not find a solution so far.