We Have a PowerShell script that has some code to connect to SharePoint. We were able to run the script successfully and establish a connection to SharePoint. The script performs the below steps:
- Gets the ADFS Url using Username from Microsoft Login Service (https://login.microsoftonline.com/GetUserRealm.srf)
- gets the SAML Assertion Xml from ADFS url using Username and Password.
- Gets the Binary Security Token using SAML Assertion Xml from Microsoft Login Service (https://login.microsoftonline.com/rst2.srf)
- gets SPOIDCRL cookie from SharePoint site by passing the binary security token(this SPOIDCRL cookie is enough for reading data).
- Gets the form digest from SharePoint Site by passing SPOIDCRL cookie (this digest is required for creating and updating data) (https://sitecollectionurl/_api/contextinfo)
- pass the SPOIDCRL cookie to read any data from SharePoint Site.
- Pass the Form Digest along with SPOIDCRL cookie to create, update or delete data in SharePoint site.
We are trying to replicate the same steps in Java and we completed the first 2 steps successfully. We are having an authentication issue while executing step 3.
I have compared the SOAP request being sent from PowerShell script and java code but I don’t see any difference except for the UUID changes.
I am attaching the error response from sharepoint in step 3.
10x800488000x80045c17PROD-WST-004.ProdSlices rid:c1133e37-6817-4c4a-912a-ad6eaff3ba00S:Senderwst:FailedAuthenticationAuthentication Failure0x80045C170x80045C17AADSTS50008: SAML token is invalid..
Does anyone know what the issue could be?
If the PowerShell and java soap request are required let me know and I can include them.