Forum Discussion
Connect-ExchangeOnline - Unauthorized
I've been searching for a solution for this error message for a couple of days now - to no avail.
Connect-ExchangeOnline through certificate always throws 'Unauthorized'.
UnAuthorized At C:\Program Files\WindowsPowerShell\Modules\ExchangeOnlineManagement\3.5.1\netFramework\ExchangeOnlineManagement.psm1:766 char:21
$tenant = '' $appId = '' $thumbprint = '' Connect-ExchangeOnline -CertificateThumbprint $thumbprint -AppId $appId -Organization $tenant
I tried:
- multiple machines
- certs in Cert:\CurrentUser\my\ and Cert:\LocalMachine\my\
- Certs are installed in the Azure AD App
- multiple networks
- PS 5.1 and 7.2
- ExchangeOnlineManagement Module versions 3.4.0 through 3.5.1
And I tried the following Graph API permissions:
As mentioned Exchange.ManageAsApp API permission does not exist any longer hence the issue.
Has anyone figured it out yet?
6 Replies
- The app needs the Exchange Online Exchange.ManageAsApp scope to be granted, not Graph ones. Refer to the documentation for detailed steps: https://learn.microsoft.com/en-us/powershell/exchange/app-only-auth-powershell-v2?view=exchange-ps#set-up-app-only-authentication
Other than that, check the certificate validity.- colonel_claypooIron Contributor
VasilMichev Yes, that used to work. But to me it seems Exchange.ManageAsApp does not exist any longer.
Would you be so kind and check on your end if the API is still available?
Thanks.- The API is still there, you're using the wrong search query. Follow the instructions in the article above.