I've been trying for days to authenticate to my Dynamics IFD/on-premise back-end, secured by ADFS. You can read all about it here. With great help from Jason Lattimer I was able to authenticate.
Which means now I can send along a SOAP security header to all my SOAP requests. The problem is, I need to use the oData REST endpoint.
I read here that you can " ... use the HttpWebRequest class to perform SOAP requests to perform the authentication part of this integration ... " and "Once you get authenticated and obtain the cookies you are free to fire REST calls off by simply providing the cookies along with the request."
Well, I am using Java, not .NET but I assumed the premise is the same. So with HttpClient I grab the cookies from the WhoAmI request (the first request, asking for a security token, doesn't return any cookies) and re-send them to an oData call. And it doesn't work, I get the login page. I think it's because there is only 1 cookie present, ReqClientId.
When you do a normal login to Dynamics in the browser, I've noticed that there are 4 cookies present:
- MSISAuth
- MSISAuth1
- ReqClientId
- MSISSignOut
I suppose the problem is, I need the MSISAuth cookies. Perhaps I'm wrong. But they are not returned. Is there any way to get them, apart from doing a browser login?
Alternatively I'd love to use oAuth instead of SOAP to perform authentication. But I'm not sure how to go about it or if it's even possible. I've seen on the net that it is, but so far haven't seen and good code examples, it's all very theoretical and abstract.