【发布时间】:2021-12-14 18:00:26
【问题描述】:
我使用 garethp php-ews 使用 oauth2 连接 EWS。我正在接收访问令牌,但是在将其传递给邮件函数(getMailItems、getMailbox、getFolder....等)时,出现“UnauthorizedException”的致命错误。尝试了很多方法,但还是一样。
致命错误:在 C:\xampp\htdocs\exchange\vendor\garethp\php-ews\src\API\ExchangeWebServices.php:453 堆栈跟踪:#0 C:中未捕获 garethp\ews\API\Exception\UnauthorizedException \xampp\htdocs\exchange\vendor\garethp\php-ews\src\API\ExchangeWebServices.php(368): garethp\ews\API\ExchangeWebServices->handleNonSuccessfulResponses(NULL, 401) #1 C:\xampp\htdocs\ exchange\vendor\garethp\php-ews\src\API\ExchangeWebServices.php(301): garethp\ews\API\ExchangeWebServices->processResponse(NULL) #2 C:\xampp\htdocs\exchange\vendor\garethp\php -ews\src\API.php(362): garethp\ews\API\ExchangeWebServices->__call('GetFolder', Array) #3 C:\xampp\htdocs\exchange\vendor\garethp\php-ews\src\ API.php(378): garethp\ews\API->getFolder(Array) #4 C:\xampp\htdocs\exchange\vendor\garethp\php-ews\src\Mail\MailAPI.php(22): garethp\ ews\API->getFolderByDistinguishedId('inbox') #5 C:\xampp\htdocs\exchange\vendor\garethp\php-ews\src\Mail\MailAPI.php(81): garethp\ews\Mail\MailAPI-> getFolderId() #6 C:\xampp\htdocs\exchange\te stSync.php(50): garethp\ews\Mail\MailAPI 在 C:\xampp\htdocs\exchange\vendor\garethp\php-ews\src\API\ExchangeWebServices.php 在第 453 行
这里是传递的参数:
$tokenEndpoint = 'https://login.microsoftonline.com/common/oauth2/v2.0/token';
$authorizationEndpoint = 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize';
$clientId = '********';
$clientSecret = '********';
$redirectUri = 'http://localhost/testredirect.php';
$scope = 'https://outlook.office.com/Mail.Read';
还尝试使用图形 API:$scope = 'https://graph.microsoft.com/Mail.Read';
【问题讨论】:
标签: php oauth-2.0 exchangewebservices php-ews