问题
If I call AuthenticationContext.AcquireToken from our service, it throws an AdalException in a certain situation because the token I’m sending is missing a required claim. The response from when I call AcquireToken contains JSON in it with the claim that is missing. I want to be able to get at that JSON (specifically the missing claim information) so I can attempt to reauthorize the user with that missing claim.
Once I catch the AdalException from calling AcquireToken, how can I get at the JSON response to find out which claim was missing? If I try to get the response stream from the innerException on the AdalException:
catch (AdalException ex)
{
WebException webex = (WebException)ex.InnerException;
WebResponse response = webex.Response;
Stream responseStream = response.GetResponseStream();
...
… then the responseStream I get has the CanRead, CanSeek, and CanWrite properties all set to false. Consequently, I’m not sure how to retrieve the missing claims parameter since I can’t actually read from that stream.
回答1:
The fix to return the entire server JSON response is made in ADAL v3. Github Link :- https://github.com/AzureAD/azure-activedirectory-library-for-dotnet/issues/513 It is not yet available in ADAL v2.
来源:https://stackoverflow.com/questions/40684961/how-can-i-retrieve-the-json-response-from-an-adalexception