AzureAD / microsoft-authentication-library-for-java

Microsoft Authentication Library (MSAL) for Java http://aka.ms/aadv2
MIT License
282 stars 137 forks source link

Fix MSI error response parsing issue #750

Closed Avery-Dunn closed 8 months ago

Avery-Dunn commented 8 months ago

Fixes the issue described in https://github.com/AzureAD/microsoft-authentication-library-for-java/issues/744

In Cloud Shell scenarios, an error response would have the form of {"error": {...}}, where the actual error info was in a JSON within the main JSON. This lead to our JSON parser throwing an exception when it tried to parse the sub-JSON like a primitive value.

This PR fixes that issue with a new method and small nested class. If the "error" field of the response is a JSON instead of a String, the JSON parsing package we use will convert it to and ErrorField field object that will then have the actual error info we're looking for. If the "error" field of the response isn't a JSON, then the existing error field will be populated and that new method won't get called.