We are creating a Java application which resets a user's password in the Office 365 AD cloud using the Graph API. We based the code primarily on the sample application located here: http://code.msdn.microsoft.com/Java-Sample-App-for-30d36d54.
The issue we are facing is that we see the following Java error message when we try to send a request for an Access Token. The error occurs randomly, and we can execute successfully requests, in both getting the token and then executing the reset request. When we don't, we see this error. The error we see is: "Exception: java.io.IOException: HTTPS hostname wrong: should be <login.windows.net>, but cert says <CN=graph.windows.net, OU=MSODS, O=Microsoft, L=Redmond, ST=WA, C=US>"