@mdma's answer is correct, you can connect your own Authenticator for authentication so that the popup does not exist.
If you are already handling authentication in a different way (for example, connection.setRequestProperty("Authorization", ...) , as this answer to another question ), you can use Authenticator.setDefault() to not use Authenticator for authentication:
Authenticator.setDefault(null);
This removes the old default Authenticator , so if your authentication is incorrect, you get an error response code through URLConnection without opening a popup.
An equivalent way is to set Authenticator to default, which returns null for getPasswordAuthentication() (which is the default implementation), as in the following code:
Authenticator.setDefault(new Authenticator() { });
But if you donβt add the code to your Authenticator , I see no reason to choose it over null .
source share