Exchange Web Services are not currently available for this request because none of the Client Access Servers in the destination site could process the request
Hi,
I am using EWS Java APIs and passing OAuth tokens to fetch data from office 365 mailboxes.
Because I am developing Web APIs I preferred using "Application Permissions" defined in Azure active directory application for Office 365, and used "client credential flow" OAuth flow to fetch OAuth token specific to application which will allow "Have full access via EWS to all mailboxes in the organisation".
After fetching token with the procedure specified in the document "http://blogs.msdn.com/b/exchangedev/archive/2015/01/21/building-demon-or-service-apps-with-office-365-mail-calendar-and-contacts-apis-oauth2-client-credential-flow.aspx"
I passed this token to EWS Java APIs,
it gave me error saying:
microsoft.exchange.webservices.data.ServiceResponseException: Exchange Web Services are not currently available for this request because none of the Client Access Servers in the destination site could process the request.
I tried similar thing with EWS managed APIs for .net. Got similar error.
Can anyone provide some help and direction to resolve this error.
Thanks & Best Regards,
Pranjal
I trying to auth with Office365 via OAuth2 using ADAL4J library. I'm success get auth token for "https://outlook.office365.com", so next step is using EWS.
ExchangeService service = new ExchangeService();
service.setCredentials(new OAuth2Credentials(authRes.getAccessToken()));
service.setTraceEnabled(true);
service.traceMessage(TraceFlags.EwsRequest, "office365");
service.setImpersonatedUserId(new ImpersonatedUserId(ConnectingIdType.SmtpAddress, "[email protected]"));
service.setUrl(new URI("https://outlook.office365.com/ews/exchange.asmx"));
class OAuth2Credentials extends ExchangeCredentials {
private String accessToken;
public OAuth2Credentials(String accessToken) {
Preconditions.checkNotNull(accessToken);
this.accessToken = accessToken;
}
@Override
public void prepareWebRequest(HttpWebRequest client)
throws URISyntaxException {
super.prepareWebRequest(client);
if (client.getHeaders() != null) client.getHeaders().put("Authorization", "Bearer " + accessToken);
}
}
and get error
microsoft.exchange.webservices.data.core.exception.service.remote.ServiceRequestException: The request failed. Exchange Web Services are not currently available for this request because none of the Client Access Servers in the destination site could process the request.
at microsoft.exchange.webservices.data.core.request.SimpleServiceRequestBase.internalExecute(SimpleServiceRequestBase.java:74)
at microsoft.exchange.webservices.data.core.request.MultiResponseServiceRequest.execute(MultiResponseServiceRequest.java:158)
at microsoft.exchange.webservices.data.core.ExchangeService.internalFindFolders(ExchangeService.java:372)
at microsoft.exchange.webservices.data.core.ExchangeService.findFolders(ExchangeService.java:421)
at microsoft.exchange.webservices.data.core.ExchangeService.findFolders(ExchangeService.java:456)
at com.stimulus.archiva.connect.exchange.rest.OAuth2.main(OAuth2.java:88)
What is correct URL to get access Office365 ? Any clue?
service.autodiscoverUrl("[email protected]");
I heard that using autoDiscovery could help, but with autoDiscovery I got other problem with infinitive connection:
19:19:21.103 [pool-1-thread-1] DEBUG c.m.aad.adal4j.AuthenticationContext - [Correlation ID: 217b22b5-f251-408b-a5da-19ad639be8cf] Using Client Http Headers: x-client-SKU=java;x-client-VER=1.0.0;x-client-OS=Mac OS X;x-client-CPU=x86_64;return-client-request-id=true;client-request-id=217b22b5-f251-408b-a5da-19ad639be8cf;
19:19:21.106 [pool-1-thread-1] INFO c.m.a.adal4j.AuthenticationAuthority - [Correlation ID: 217b22b5-f251-408b-a5da-19ad639be8cf] Instance discovery was successful
19:19:21.853 [pool-1-thread-1] DEBUG c.m.aad.adal4j.AuthenticationContext - [Correlation ID: 217b22b5-f251-408b-a5da-19ad639be8cf] Access Token with hash 'lQOnxt3PB5s-5PZrsanGGJlQx0IfMwDrwDVo0qrKKNQ' returned
Success: eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik1uQ19WWmNBVGZNNXBPWWlKSE1iYTlnb0VLWSIsImtpZCI6Ik1uQ19WWmNBVGZNNXBPWWlKSE1iYTlnb0VLWSJ9.eyJhdWQiOiJodHRwczovL291dGxvb2sub2ZmaWNlMzY1LmNvbSIsImlzcyI6Imh0dHBzOi8vc3RzLndpbmRvd3MubmV0L2QwNjk4YTkxLTIzYmEtNDQ5NS1hYmRiLTU4NjQ3OTNjNDhkYy8iLCJpYXQiOjE0MzI5MTI0NjEsIm5iZiI6MTQzMjkxMjQ2MSwiZXhwIjoxNDMyOTE2MzYxLCJ2ZXIiOiIxLjAiLCJ0aWQiOiJkMDY5OGE5MS0yM2JhLTQ0OTUtYWJkYi01ODY0NzkzYzQ4ZGMiLCJyb2xlcyI6WyJmdWxsX2FjY2Vzc19hc19hcHAiLCJNYWlsLlJlYWRXcml0ZSIsIkNhbGVuZGFycy5SZWFkIiwiQ29udGFjdHMuUmVhZFdyaXRlIiwiTWFpbC5SZWFkIiwiQ2FsZW5kYXJzLlJlYWRXcml0ZSIsIk1haWwuU2VuZCIsIkNvbnRhY3RzLlJlYWQiXSwib2lkIjoiZTRjZTc2MzQtYjEyYi00ODdmLWEwZjYtYzMxOWI4Mjc2NWZjIiwic3ViIjoiZTRjZTc2MzQtYjEyYi00ODdmLWEwZjYtYzMxOWI4Mjc2NWZjIiwiaWRwIjoiaHR0cHM6Ly9zdHMud2luZG93cy5uZXQvZDA2OThhOTEtMjNiYS00NDk1LWFiZGItNTg2NDc5M2M0OGRjLyIsImFwcGlkIjoiZTIzNDI1ZTktYjJhMi00OTQwLThiZTktMjFjZDc0NjcxNTEzIiwiYXBwaWRhY3IiOiIyIn0.C0QMSmujxZF7QTbrBWflzjtTIcFbgzC7XtI1HDkf3VTMK5T6kLs_ut0sCxeBjHd6wzKADqwQw7MaaC86ougKsd9_FAA7ihiTYTh1Im6ufGQxxbHiOe9dnc7NsjjrSxE_SPJx-bE2deNwdJ9wg1nqxGF4QjNMGAdw-SMcq838eOac3OMHZoH7l6wFmvLhnj-bpoaMfx2YE7ZCbEyf-0JvpVdegIQIr0Yw1rDSyXx-6yo_3agKt42xUcxEGCo32GMB2WwD3nrDmgg8u1C5bNVp9GlDCkjFCjpa7QDMrdBtIBTL2MJJ1vi71o4ODO-_2qIiNbOIFlQMftQOPxGSjZ_0YQ
19:19:22.101 [main] DEBUG o.a.h.c.protocol.RequestAddCookies - CookieSpec selected: default
19:19:22.110 [main] DEBUG o.a.h.c.protocol.RequestAuthCache - Auth cache not set in the context
19:19:22.112 [main] DEBUG o.a.h.i.c.BasicHttpClientConnectionManager - Get connection for route {s}->https://archiva360.com:443
19:19:22.124 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Opening connection {s}->https://archiva360.com:443
19:19:22.403 [main] DEBUG o.a.h.i.c.DefaultHttpClientConnectionOperator - Connecting to archiva360.com/184.168.221.57:443
19:19:22.403 [main] DEBUG m.e.w.d.c.EwsSSLProtocolSocketFactory - Connecting socket to archiva360.com/184.168.221.57:443 with timeout 0
19:19:22.604 [main] DEBUG m.e.w.d.c.EwsSSLProtocolSocketFactory - Enabled protocols: [TLSv1]
19:19:22.604 [main] DEBUG m.e.w.d.c.EwsSSLProtocolSocketFactory - Enabled cipher suites:[TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDH_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_DSS_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, TLS_ECDHE_RSA_WITH_RC4_128_SHA, SSL_RSA_WITH_RC4_128_SHA, TLS_ECDH_ECDSA_WITH_RC4_128_SHA, TLS_ECDH_RSA_WITH_RC4_128_SHA, TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_RSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA, SSL_RSA_WITH_RC4_128_MD5, TLS_EMPTY_RENEGOTIATION_INFO_SCSV]
19:19:22.604 [main] DEBUG m.e.w.d.c.EwsSSLProtocolSocketFactory - Starting handshake
19:19:23.013 [main] DEBUG o.a.h.i.c.DefaultManagedHttpClientConnection - http-outgoing-0: Shutdown connection
19:19:23.013 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Connection discarded
19:19:23.013 [main] DEBUG o.a.h.i.c.BasicHttpClientConnectionManager - Releasing connection [Not bound]
19:19:23.014 [main] INFO o.a.http.impl.execchain.RetryExec - I/O exception (java.net.SocketException) caught when processing request to {s}->https://archiva360.com:443: Connection reset
19:19:23.021 [main] DEBUG o.a.http.impl.execchain.RetryExec - Connection reset
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:196) ~[na:1.7.0_67]
at java.net.SocketInputStream.read(SocketInputStream.java:122) ~[na:1.7.0_67]
at sun.security.ssl.InputRecord.readFully(InputRecord.java:442) ~[na:1.7.0_67]
at sun.security.ssl.InputRecord.read(InputRecord.java:480) ~[na:1.7.0_67]
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:927) ~[na:1.7.0_67]
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1312) ~[na:1.7.0_67]
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1339) ~[na:1.7.0_67]
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1323) ~[na:1.7.0_67]
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:394) ~[httpclient-4.4.1.jar:4.4.1]
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:353) ~[httpclient-4.4.1.jar:4.4.1]
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:134) ~[httpclient-4.4.1.jar:4.4.1]
at org.apache.http.impl.conn.BasicHttpClientConnectionManager.connect(BasicHttpClientConnectionManager.java:338) ~[httpclient-4.4.1.jar:4.4.1]
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380) ~[httpclient-4.4.1.jar:4.4.1]
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236) ~[httpclient-4.4.1.jar:4.4.1]
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184) ~[httpclient-4.4.1.jar:4.4.1]
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88) ~[httpclient-4.4.1.jar:4.4.1]
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110) [httpclient-4.4.1.jar:4.4.1]
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184) [httpclient-4.4.1.jar:4.4.1]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82) [httpclient-4.4.1.jar:4.4.1]
at microsoft.exchange.webservices.data.core.request.HttpClientWebRequest.executeRequest(HttpClientWebRequest.java:292) [ews-java-api-2.0-SNAPSHOT.jar:na]
at microsoft.exchange.webservices.data.autodiscover.AutodiscoverService.tryGetEnabledEndpointsForHost(AutodiscoverService.java:1531) [ews-java-api-2.0-SNAPSHOT.jar:na]
at microsoft.exchange.webservices.data.autodiscover.AutodiscoverService.tryGetAutodiscoverEndpointUrl(AutodiscoverService.java:1349) [ews-java-api-2.0-SNAPSHOT.jar:na]
at microsoft.exchange.webservices.data.autodiscover.AutodiscoverService.getSettings(AutodiscoverService.java:1136) [ews-java-api-2.0-SNAPSHOT.jar:na]
at microsoft.exchange.webservices.data.autodiscover.AutodiscoverService.getUserSettings(AutodiscoverService.java:1044) [ews-java-api-2.0-SNAPSHOT.jar:na]
at microsoft.exchange.webservices.data.autodiscover.AutodiscoverService.internalGetSoapUserSettings(AutodiscoverService.java:988) [ews-java-api-2.0-SNAPSHOT.jar:na]
at microsoft.exchange.webservices.data.autodiscover.AutodiscoverService.getUserSettings(AutodiscoverService.java:1849) [ews-java-api-2.0-SNAPSHOT.jar:na]
at microsoft.exchange.webservices.data.core.ExchangeService.getAutodiscoverUrl(ExchangeService.java:3611) [ews-java-api-2.0-SNAPSHOT.jar:na]
at microsoft.exchange.webservices.data.core.ExchangeService.autodiscoverUrl(ExchangeService.java:3539) [ews-java-api-2.0-SNAPSHOT.jar:na]
at microsoft.exchange.webservices.data.core.ExchangeService.autodiscoverUrl(ExchangeService.java:3520) [ews-java-api-2.0-SNAPSHOT.jar:na]
at com.stimulus.archiva.connect.exchange.rest.OAuth2.main(OAuth2.java:86) [classes/:na]
19:19:23.021 [main] INFO o.a.http.impl.execchain.RetryExec - Retrying request to {s}->https://archiva360.com:443
19:19:23.021 [main] DEBUG o.a.h.c.protocol.RequestAddCookies - CookieSpec selected: default
19:19:23.021 [main] DEBUG o.a.h.c.protocol.RequestAuthCache - Auth cache not set in the context
19:19:23.021 [main] DEBUG o.a.h.i.c.BasicHttpClientConnectionManager - Get connection for route {s}->https://archiva360.com:443
19:19:23.021 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Opening connection {s}->https://archiva360.com:443
19:19:23.021 [main] DEBUG o.a.h.i.c.DefaultHttpClientConnectionOperator - Connecting to archiva360.com/184.168.221.57:443
19:19:23.022 [main] DEBUG m.e.w.d.c.EwsSSLProtocolSocketFactory - Connecting socket to archiva360.com/184.168.221.57:443 with timeout 0
19:19:23.324 [main] DEBUG o.a.h.i.c.DefaultManagedHttpClientConnection - http-outgoing-1: Shutdown connection
19:19:23.324 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Connection discarded
19:19:23.324 [main] DEBUG o.a.h.i.c.BasicHttpClientConnectionManager - Releasing connection [Not bound]
19:19:23.324 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Cancelling request execution
19:19:23.328 [main] DEBUG o.a.h.c.protocol.RequestAddCookies - CookieSpec selected: default
19:19:23.328 [main] DEBUG o.a.h.c.protocol.RequestAuthCache - Auth cache not set in the context
19:19:23.328 [main] DEBUG o.a.h.i.c.BasicHttpClientConnectionManager - Get connection for route {s}->https://autodiscover.archiva360.com:443
19:19:23.328 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Opening connection {s}->https://autodiscover.archiva360.com:443
19:19:23.677 [main] DEBUG o.a.h.i.c.DefaultHttpClientConnectionOperator - Connecting to autodiscover.archiva360.com/132.245.224.200:443
19:19:23.677 [main] DEBUG m.e.w.d.c.EwsSSLProtocolSocketFactory - Connecting socket to autodiscover.archiva360.com/132.245.224.200:443 with timeout 0
19:19:23.741 [main] DEBUG o.a.h.i.c.DefaultHttpClientConnectionOperator - Connect to autodiscover.archiva360.com/132.245.224.200:443 timed out. Connection will be retried using another IP address
19:19:23.742 [main] DEBUG o.a.h.i.c.DefaultHttpClientConnectionOperator - Connecting to autodiscover.archiva360.com/132.245.176.72:443
19:19:23.742 [main] DEBUG m.e.w.d.c.EwsSSLProtocolSocketFactory - Connecting socket to autodiscover.archiva360.com/132.245.176.72:443 with timeout 0
19:19:23.801 [main] DEBUG o.a.h.i.c.DefaultHttpClientConnectionOperator - Connect to autodiscover.archiva360.com/132.245.176.72:443 timed out. Connection will be retried using another IP address
19:19:23.802 [main] DEBUG o.a.h.i.c.DefaultHttpClientConnectionOperator - Connecting to autodiscover.archiva360.com/132.245.48.24:443
19:19:23.802 [main] DEBUG m.e.w.d.c.EwsSSLProtocolSocketFactory - Connecting socket to autodiscover.archiva360.com/132.245.48.24:443 with timeout 0
19:19:23.860 [main] DEBUG o.a.h.i.c.DefaultHttpClientConnectionOperator - Connect to autodiscover.archiva360.com/132.245.48.24:443 timed out. Connection will be retried using another IP address
19:19:23.861 [main] DEBUG o.a.h.i.c.DefaultHttpClientConnectionOperator - Connecting to autodiscover.archiva360.com/132.245.36.104:443
19:19:23.861 [main] DEBUG m.e.w.d.c.EwsSSLProtocolSocketFactory - Connecting socket to autodiscover.archiva360.com/132.245.36.104:443 with timeout 0
19:19:23.923 [main] DEBUG o.a.h.i.c.DefaultHttpClientConnectionOperator - Connect to autodiscover.archiva360.com/132.245.36.104:443 timed out. Connection will be retried using another IP address
19:19:23.924 [main] DEBUG o.a.h.i.c.DefaultHttpClientConnectionOperator - Connecting to autodiscover.archiva360.com/132.245.193.136:443
19:19:23.924 [main] DEBUG m.e.w.d.c.EwsSSLProtocolSocketFactory - Connecting socket to autodiscover.archiva360.com/132.245.193.136:443 with timeout 0
19:19:23.982 [main] DEBUG o.a.h.i.c.DefaultHttpClientConnectionOperator - Connect to autodiscover.archiva360.com/132.245.193.136:443 timed out. Connection will be retried using another IP address
19:19:23.983 [main] DEBUG o.a.h.i.c.DefaultHttpClientConnectionOperator - Connecting to autodiscover.archiva360.com/191.234.224.8:443
19:19:23.983 [main] DEBUG m.e.w.d.c.EwsSSLProtocolSocketFactory - Connecting socket to autodiscover.archiva360.com/191.234.224.8:443 with timeout 0
19:19:24.033 [main] DEBUG o.a.h.i.c.DefaultHttpClientConnectionOperator - Connect to autodiscover.archiva360.com/191.234.224.8:443 timed out. Connection will be retried using another IP address
19:19:24.033 [main] DEBUG o.a.h.i.c.DefaultHttpClientConnectionOperator - Connecting to autodiscover.archiva360.com/191.234.224.184:443
19:19:24.033 [main] DEBUG m.e.w.d.c.EwsSSLProtocolSocketFactory - Connecting socket to autodiscover.archiva360.com/191.234.224.184:443 with timeout 0
19:19:24.085 [main] DEBUG o.a.h.i.c.DefaultHttpClientConnectionOperator - Connect to autodiscover.archiva360.com/191.234.224.184:443 timed out. Connection will be retried using another IP address
19:19:24.085 [main] DEBUG o.a.h.i.c.DefaultHttpClientConnectionOperator - Connecting to autodiscover.archiva360.com/132.245.61.232:443
19:19:24.085 [main] DEBUG m.e.w.d.c.EwsSSLProtocolSocketFactory - Connecting socket to autodiscover.archiva360.com/132.245.61.232:443 with timeout 0
19:19:24.154 [main] DEBUG o.a.h.i.c.DefaultHttpClientConnectionOperator - Connect to autodiscover.archiva360.com/132.245.61.232:443 timed out. Connection will be retried using another IP address
19:19:24.155 [main] DEBUG o.a.h.i.c.DefaultHttpClientConnectionOperator - Connecting to autodiscover.archiva360.com/132.245.229.184:443
19:19:24.155 [main] DEBUG m.e.w.d.c.EwsSSLProtocolSocketFactory - Connecting socket to autodiscover.archiva360.com/132.245.229.184:443 with timeout 0
19:19:24.200 [main] DEBUG o.a.h.i.c.DefaultHttpClientConnectionOperator - Connect to autodiscover.archiva360.com/132.245.229.184:443 timed out. Connection will be retried using another IP address
19:19:24.201 [main] DEBUG o.a.h.i.c.DefaultHttpClientConnectionOperator - Connecting to autodiscover.archiva360.com/2a01:111:f400:8400:0:0:0:8:443
19:19:24.201 [main] DEBUG m.e.w.d.c.EwsSSLProtocolSocketFactory - Connecting socket to autodiscover.archiva360.com/2a01:111:f400:8400:0:0:0:8:443 with timeout 0
Hi @valenpo I have answers to your both questions:
(1) I was able to resolve your first issue by adding follwing line of code: service.getHttpHeaders().put("X-AnchorMailbox","smtpemailaddress"); smtpmailaddress should be emailid of the user you are trying to impersonate.
(2) To resolve issue related to autodiscovery: Add following line of code: service.setWebProxy(new WebProxy(proxyHost,proxyPort)); where proxyHost and proxyPort are the system properties of the JVM or machine in which you are running your application, which you can easily get by following code: String proxyHost=System.getProperty("http.proxyHost");
Hope both solutions wotk for you! Regards, Pranjal
Hi @pranjaljain Thank you 1. definitely working. Maybe made some new class to make OAuth2 more friendly to use?
Regards, Valentin
Hi @valenpo I am also one of the users of ews-java api, we have also requested for new class to handle oauth2 as already present in ews managed api for .net. I think it will take some time. For 2nd issue related to autodiscovery some more information I would like to share. This issue comes when your internal network is not able to resolve host. If you are running your application within corporate network of your organisation may be the firewall is blocking it. You can try running application on public Internet network.
Regards, Pranjal
Hi @pranjaljain As you see on mine code example, it did the trick with OAuth2. Access token I got via adal4j library.
class OAuth2Credentials extends ExchangeCredentials {
private String accessToken;
public OAuth2Credentials(String accessToken) {
Preconditions.checkNotNull(accessToken);
this.accessToken = accessToken;
}
@Override
public void prepareWebRequest(HttpWebRequest client)
throws URISyntaxException {
super.prepareWebRequest(client);
if (client.getHeaders() != null) client.getHeaders().put("Authorization", "Bearer " + accessToken);
}
}
Hi,
I using the code below and still get the exception. (using ews-java-api 2.0)
service.setCredentials(new ExchangeCredentials() {
@Override
public void prepareWebRequest(HttpWebRequest client) throws URISyntaxException {
super.prepareWebRequest(client);
client.getHeaders().put(HttpHeaders.AUTHORIZATION, "Bearer" + " " + accessToken);
client.getHeaders().put("X-AnchorMailbox", userEmail);
}
});
Thanks, Sergiu