jamesiarmes / php-ews

PHP Exchange Web Services
http://jamesarmes.com/php-ews/
MIT License
568 stars 305 forks source link

Exchange Online Basic Auth Deprecation – In Progress #615

Open nestyxx opened 1 year ago

nestyxx commented 1 year ago

Hello jamesiarmes.

I'm currently in a hurry on several projects that were still using basic authentication to interact with Exchange calendars. Unfortunately, Microsoft 365 has just disabled the function and I am desperately looking for a solution to identify myself otherwise (example Oauth2).

Today we use the following code:

$client = new Client($host, $username, $password, $version);

Despite several tests following all the "msgraph-sdk-php" documentation to generate a token, I couldn't identify myself. The goal is to use the existing code but only change the authentication method.

$client = new Client("outlook.office365.com", Client::VERSION_2016);
$client->authWithOauth2("your-access-token");
// $client->authWithUserAndPass($username, $password);

If anyone has an idea of how to proceed, I remain interested. Thanks in advance for your feedback. Alexandre

nestyxx commented 1 year ago

I finally managed to generate an "accessToken" but despite that, I can no longer read the desired calendar.

$client = new Client("outlook.office365.com", Client::VERSION_2016);
$client->authWithOauth2($accessToken);
$client->authWithUserAndPass($username, $password);
$client->setTimezone($timezone);