private static AuthenticationParameters CreateFromUnauthorizedResponseCommon(IHttpWebResponse response)
{
if (response == null)
{
throw new ArgumentNullException("response");
}
AuthenticationParameters authParams;
if (response.StatusCode == HttpStatusCode.Unauthorized)
{
if (response.Headers.Keys.Contains(AuthenticateHeader))
{
authParams = CreateFromResponseAuthenticateHeader(response.Headers[AuthenticateHeader]);
}
else
{
var ex = new ArgumentException(MsalErrorMessage.MissingAuthenticateHeader, "response");
PlatformPlugin.Logger.Error(null, ex);
throw ex;
}
}
else
{
var ex = new ArgumentException(MsalErrorMessage.UnauthorizedHttpStatusCodeExpected, "response");
PlatformPlugin.Logger.Error(null, ex);
throw ex;
}
return authParams;
}
}