Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authorization stopped working suddenly #239

Open
boindil opened this issue Oct 19, 2022 · 1 comment
Open

Authorization stopped working suddenly #239

boindil opened this issue Oct 19, 2022 · 1 comment

Comments

@boindil
Copy link

boindil commented Oct 19, 2022

Hi,
the authorization suddenly stopped working without me doing anything. No password changes, no code changes. Might this be related to microsoft disabling basic auth?

@Garethp maybe you have any ideas? My code can only run fully unattended (printing specific mails and faxes). If it's actually basic-auth related, how to solve without user interaction? :/

	$host           = 'outlook.office365.com';
	$username       = 'xxx1@xxx.com';
	$password       = '';
	$email          = 'xxx2@xxx.com';
	
	$api = \garethp\ews\MailAPI::withUsernameAndPassword(
		$host,
		$username,
		$password,
		[
			'primarySmtpEmailAddress' => $email
		]
	);
	$box = $api->getFolderByDistinguishedId('inbox');
	$items = $api->getMailItems($box->getFolderId());
PHP Fatal error:  Uncaught garethp\ews\API\Exception\UnauthorizedException in /root/autoprint/vendor/garethp/php-ews/src/API/ExchangeWebServices.php:454
Stack trace:
#0 /root/autoprint/vendor/garethp/php-ews/src/API/ExchangeWebServices.php(372): garethp\ews\API\ExchangeWebServices->handleNonSuccessfulResponses(NULL, 401)
#1 /root/autoprint/vendor/garethp/php-ews/src/API/ExchangeWebServices/MiddlewareFactory.php(57): garethp\ews\API\ExchangeWebServices->processResponse(NULL)
#2 /root/autoprint/vendor/garethp/php-ews/src/API/ExchangeWebServices.php(516): garethp\ews\API\ExchangeWebServices->garethp\ews\API\ExchangeWebServices\{closure}(Object(garethp\ews\API\MiddlewareRequest), Object(Closure))
#3 /root/autoprint/vendor/garethp/php-ews/src/API/ExchangeWebServices/MiddlewareFactory.php(66): garethp\ews\API\ExchangeWebServices->garethp\ews\API\{closure}(Object(garethp\ews\API\MiddlewareRequest))
#4 /root/autoprint/vendor/garethp/php-ews/src/API/ExchangeWebServices.php(516): garethp\ews\API\ExchangeWebServices->garethp\ews\API\Exch in /root/autoprint/vendor/garethp/php-ews/src/API/ExchangeWebServices.php on line 454
@tguk70
Copy link

tguk70 commented Oct 19, 2022

It's related to basic auth as I am having the same issue with my powershell scripts and having to use oAuth instead. Check on the Microsoft exchange web services page to find your alternative method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants