I have a java/j2ee web application consuming SP web services but recently the SP site got migrated to 2013 and deployed in cloud/office 0365 due to which authentication got broken. SP people suggested to change authentication mechanism to SAML token based authentication and use Microsoft Azure AD. So i on boarded my application into Azure and received Client ID, Authority using which i am able to generate security token(used adal4j java api) . Now i need to complete below 2 steps to complete the authentication process in office 0365 to access SP 2013 web services.
- Get access token cookies
- Get request digest token
But not able to find any java based API for above 2 steps. Refereed below tutorial buts its something related to aps/.net
http://paulryan.com.au/2014/spo-remote-authentication-rest/
Please help me in providing sample code base for the same.
Appreciate your support
Per my experience, I think you can try to directly follow your refered article step by step to use the Apache HttpClient to construct the request.
For example, the code below is using the
HttpClient
to do the post request with the xml body to get the security token.You can try to follow the code above to get the response includes access token via do the post request with the security token body for the url
https://yourdomain.sharepoint.com/_forms/default.aspx?wa=wsignin1.0
, and use the codeHeader[] hs = response.getHeaders("Set-Cookie");
to get theSet-Cookie
header array as access token.Then using them to set the two headers
Cookie
for getting the request digest token, and parse the response body to extract theFormDigestValue
as the request digest token.