Error: Access is denied. Check credentials and try again. when using service account.
I have a shared mailbox in exchange. Using the api I can connect fine using my personal credentials, specifying username/password. This mailbox access is controlled by an AD group. When I try using a service account it fails with the stack trace.
Exception in thread "main" microsoft.exchange.webservices.data.core.exception.service.remote.ServiceResponseException: Access is denied. Check credentials and try again.
at microsoft.exchange.webservices.data.core.response.ServiceResponse.internalThrowIfNecessary(ServiceResponse.java:278)
at microsoft.exchange.webservices.data.core.response.ServiceResponse.throwIfNecessary(ServiceResponse.java:267)
at microsoft.exchange.webservices.data.core.request.MultiResponseServiceRequest.execute(MultiResponseServiceRequest.java:165)
at microsoft.exchange.webservices.data.core.ExchangeService.findItems(ExchangeService.java:985)
at microsoft.exchange.webservices.data.core.ExchangeService.findItems(ExchangeService.java:1049)
at abbvie.ir.pikm.assistance.ConnectionTest.processInboxItems(ConnectionTest.java:44)
at abbvie.ir.pikm.assistance.ConnectionTest.main(ConnectionTest.java:80)
Any suggestions?
I am seeing the same. I started out getting the App-only token to ensure my app is authorized by the admin to silently perform actions across all users. The token has the permissions required to access EWS APIs. However I get a 401 Unauthorized instead of the error your seeing.
Exception in thread "main" microsoft.exchange.webservices.data.core.exception.service.remote.ServiceRequestException: The request failed. The request failed. The remote server returned an error: (401)Unauthorized
at microsoft.exchange.webservices.data.core.request.SimpleServiceRequestBase.internalExecute(SimpleServiceRequestBase.java:74)
at microsoft.exchange.webservices.data.core.request.GetInboxRulesRequest.execute(GetInboxRulesRequest.java:143)
at microsoft.exchange.webservices.data.core.ExchangeService.getInboxRules(ExchangeService.java:3459)
at com.paloaltonetworks.aperture.token.ExchangeTokenService.getRules(ExchangeTokenService.java:164)
at com.paloaltonetworks.aperture.token.ExchangeTokenService.main(ExchangeTokenService.java:193)
Caused by: microsoft.exchange.webservices.data.core.exception.service.remote.ServiceRequestException: The request failed. The remote server returned an error: (401)Unauthorized
at microsoft.exchange.webservices.data.core.request.ServiceRequestBase.validateAndEmitRequest(ServiceRequestBase.java:644)
at microsoft.exchange.webservices.data.core.request.SimpleServiceRequestBase.internalExecute(SimpleServiceRequestBase.java:62)
... 4 more
Caused by: microsoft.exchange.webservices.data.core.exception.http.HttpErrorException: The remote server returned an error: (401)Unauthorized
at microsoft.exchange.webservices.data.core.request.ServiceRequestBase.getEwsHttpWebResponse(ServiceRequestBase.java:723)
at microsoft.exchange.webservices.data.core.request.ServiceRequestBase.validateAndEmitRequest(ServiceRequestBase.java:639)
... 5 more
Is this because I cannot use the token I got for 'graph.microsoft.com' with the admin access? If not which token should I use and how do I go about getting it?