You're getting the relevant error code back from Azure AD - 65004, telling you the root cause, that Admin has declined to consent. Description is visible in the URL and if you can confirm the meaning of error code by looking it up here -
Sign-in activity report error codes in the Azure Active Directory portal
65004 User declined to consent to access the app. Have the user retry
the sign-in and consent to the app
Update about displaying a meaningful error page
You haven't mentioned what is it that you're using to write your web application. In any case, I tried out a quick ASP.NET MVC web application with similar setup and I clearly get back the response in query string parameters. All you need to do is, read the query string from the URL (I have HttpRequest.QueryString collection in my sample) and check for error/error_description.
Here is a quick sample code on doing that in the MVC controller..
public class AdminConsentController : Controller
{
// GET: AdminConsent
public ActionResult Index()
{
if (Request.QueryString.AllKeys.Contains("error")
&& Request.QueryString.AllKeys.Contains("error_description"))
{
string errorDescription = Request.QueryString["error_description"];
if(errorDescription.Contains("AADSTS65005"))
{
//Do something good about it..
}
}
//if no errors, simply return the view
return View();
}
Since you mention Angular 5.. here's a quick sample for that.
Take a look at this SO post for multiple options
ngOnInit() {
this.param1 = this.route.snapshot.paramMap.get('param1');
this.param2 = this.route.snapshot.paramMap.get('param2');
}
And if you don't want to use anything fancy, plain old window.location should always work from client side. May not be the recommended way though.
window.location.href