OAuth with EWS Java APIs
Hi ,
We found there is Limitation in EWS Java APIs: EWS Java APIs that we download from https://github.com/OfficeDev/ews-java-api only Support EWS features till Exchange2010_SP2, it does have any special classes to pass OAuth token. EWS Managed APIs for .net has the Microsoft.Exchange.WebServices.Data.OAuthCredentials class through which we can pass OAuth token but till now EWS Managed Java APIs has not provided that class.
So, we need to pass OAuth token as authorization header.
Also, when I tried passing “Bearer” type OAuth token as authorization header, service.getHttpHeaders().put("Authorization", "Bearer
service.getHttpHeaders().put("Authorization", "Bearer ");
Could someone from you team make this changes or you can suggest any other solution.
Thanks & Regards, Showkath.
@nshowkath thanks for the given input. Maybe just commenting out the validation process might not be the best solution for this problem. At some point we should see differences between the ews-managed-api and ews-java-api and show up the points we should have implemented in both of them (regarding "costs" and the timeline).
Hi,
Thanks for your reply , could you let me know when can we expect this change in EWS JAVA API
Thanks, Showkath.
@nshowkath see #288 for details. But this will depend on the number of PR coming in.
Thanks for your reply and considering it as enchantment . It would be great if your team get it done at earliest and give high priority to this requirement , otherwise we need to include your source code as part of our solution, which will causes future problem when your team implemented any new feature. Please let me know if you need more inputs on this issue or any support from me.
Thanks, Showkath.
I did look into this and noticed that when this validation was added it was mainly motivated by the need to add an X- header. I also checked ews-managed-api latest code of ExchangeServiceBase no longer has this check. Digging into the history, the check was removed on 2012-MAR-20.
So I suggest removing the check within the validate method to be consistent with the EWS Managed API. This enables adding any headers including the authorization header and hence unblocking the OAuth scenario.
Then later, we can still add OAuth support as a first class feature so that users of the library don't need to provide custom headers. This will also bring ews-java-api to parity with ews-managed-api.
@serious6 do you have concerns about such approach? @nshowkath will this change address your concern?
sounds good to me :+1:
Yes , this will resolve issue, could you let me know when can we expect this change in EWS JAVA API ?
Thanks, Showkath.
Hi ! I need to authenticate to my EWS through a LtpaToken2 cookie .. is that possible? My web application is running under a WebSphere that haves a Single-Sign-On configuration (SPNEGO) .. So the credentials are negotiated between the browser - the websphere - and the active directory ... and when the user is authenticated a LtpaToken2 cookie is set into the response
Is that possible ?? Thanks !
Hi All.. How to use the java ews api to authenticate an user?? Please provide me a java code. I have been looking for this every where and ended up asking here. Please reply at the earliest.
Hi @girish-kumar-710 have you found any java code for office365 oauth using EWS or any api? If so, can u plz share with me. Thanks.
I can not find "office 365 exchange online" on add application in Azure Active Directory when register a new application to use oauth. And only find Microsoft Graph Permissions on the new Application Registration Porta(https://apps.dev.microsoft.com). Could you tell me where can I register my app to use oauth with ews-java-api ? @serious6
I am not sure if the change fixed it. I have the app-only token I got from graph.microsoft.com using the client-credentials grant flow and seems like I cannot use that for EWS API? I was able to validate that the token is passed via the wire with the Authorization header set with the token but I still get 401 unauthorized.
Does EWS even support access tokens received from client-credentials grant flow? Please help.
Can anyone please tell me. Is this enough the below code will validate our user validation?
service.getHttpHeaders().put("Authorization", "Bearer ");
Yes. It will work fine. Give as like this. Generate the Access token via Oauth2.
service.getHttpHeaders().put("Authorization", "Bearer " + accessToken);
Thank you @samrajcse . I have passed the username and password for a validation it is working fine. without password will it be possible to validate the EWS by using user access token. If the user access token is enough to validate please tell me the procedure how to get an access token?
Please help me on that.
You can follow the below steps to get the access token. We need to have Oath2 flow to generate tokens.
https://blogs.msdn.microsoft.com/exchangedev/2014/03/25/using-oauth2-to-access-calendar-contact-and-mail-api-in-office-365-exchange-online/
Regards, SAMRAJ.K
On Thu, Jul 19, 2018 at 3:09 PM ShanavazJs [email protected] wrote:
Thank you @samrajcse https://github.com/samrajcse . I have passed the username and password for a validation it is working fine. without password will it be possible to validate the EWS by using user access token. If the user access token is enough to validate please tell me the procedure how to get an access token?
Please help me on that.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/OfficeDev/ews-java-api/issues/284#issuecomment-406217742, or mute the thread https://github.com/notifications/unsubscribe-auth/AAqinNvml2gz1C2FpsINLVO12ZfOsTsjks5uIFO-gaJpZM4D7eam .
when im trying to call ews api using access token it giving error :microsoft.exchange.webservices.data.core.exception.service.remote.ServiceRequestException: The request failed. The request failed. The remote server returned an error: (401)Unauthorized
To avoid getting unauthorized pass scope : https://outlook.office.com/.default not https://graph.microsoft.com/.default