How can I retrieve the JSON response from an AdalException?

送分小仙女□ 提交于 2019-12-12 03:54:34

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!