Java Proxy Authentication For Web Requests

HTTP 407 proxy authentication required Fix

Proxy authentication in Java

The usual corporate networks provide internet access via proxy servers and at times they require authentication as well. May applications do open the connections to servers which are external to the corporate intranet. So one has to do proxy authentication programmatically. Fortunately Java provides a transparent mechanism to do proxy authentications.


Create a simple class like below:

import java.net.Authenticator;

class ProxyAuthenticator extends Authenticator {

    private String user, password;

    public ProxyAuthenticator(String user, String password) {
        this.user = user;
        this.password = password;
    }

    protected PasswordAuthentication getPasswordAuthentication() {
        return new PasswordAuthentication(user, password.toCharArray());
    }
}

and put these lines of code before your code opens an URLConnection-

Authenticator.setDefault(new ProxyAuthenticator("user", "password"));
System.setProperty("http.proxyHost", "proxy host");
System.setProperty("http.proxyPort", "port");

Now all calls will successfully pass through the proxy authentication.

Get Full Access To All Of Our Residential Proxies.

Residential Plans
Mobile Plans

Pay As You Go

1 GB
$15
  • $15 per GB
  • No Expiration
  • 170+ Countries
  • 24/7 Support
  • HTTP & SOCKS5
  • City & ISP Targeting
  • Unlimited Threads
  • Rollover bandwidth

Starter

3GB
$40
  • $13.3 per GB
  • No Expiration
  • 170+ Countries
  • 24/7 Support
  • HTTP & SOCKS5
  • City & ISP Targeting
  • Unlimited Threads
  • Rollover bandwidth

Hobby

15GB
$150
  • $10 per GB
  • No Expiration
  • 170+ Countries
  • 24/7 Support
  • HTTP & SOCKS5
  • City & ISP Targeting
  • Unlimited Threads
  • Rollover bandwidth

Startup

40GB
$300
  • $7.5 per GB
  • No Expiration
  • 170+ Countries
  • 24/7 Support
  • HTTP & SOCKS5
  • City & ISP Targeting
  • Unlimited Threads
  • Rollover bandwidth

Business

100GB
$600
  • $6 per GB
  • No Expiration
  • 170+ Countries
  • 24/7 Support
  • HTTP & SOCKS5
  • City & ISP Targeting
  • Unlimited Threads
  • Rollover bandwidth

Company

250GB
$1250
  • $5 per GB
  • No Expiration
  • 170+ Countries
  • 24/7 Support
  • HTTP & SOCKS5
  • City & ISP Targeting
  • Unlimited Threads
  • Rollover bandwidth

Pay As You Go

1 GB
$30
  • $30 per GB
  • No Expiration
  • 170+ Countries
  • 24/7 Support
  • HTTP & SOCKS5
  • City & ISP Targeting
  • Unlimited Threads
  • Rollover bandwidth

Mobile A

2GB
$60
  • $30 per GB
  • No Expiration
  • 170+ Countries
  • 24/7 Support
  • HTTP & SOCKS5
  • City & ISP Targeting
  • Unlimited Threads
  • Rollover bandwidth

Mobile S

5GB
$150
  • $30 per GB
  • No Expiration
  • 170+ Countries
  • 24/7 Support
  • HTTP & SOCKS5
  • City & ISP Targeting
  • Unlimited Threads
  • Rollover bandwidth

Mobile M

12GB
$300
  • $25 per GB
  • No Expiration
  • 170+ Countries
  • 24/7 Support
  • HTTP & SOCKS5
  • City & ISP Targeting
  • Unlimited Threads
  • Rollover bandwidth

Mobile L

30GB
$660
  • $22 per GB
  • No Expiration
  • 170+ Countries
  • 24/7 Support
  • HTTP & SOCKS5
  • City & ISP Targeting
  • Unlimited Threads
  • Rollover bandwidth

Mobile XL

85GB
$1530
  • $18 per GB
  • No Expiration
  • 170+ Countries
  • 24/7 Support
  • HTTP & SOCKS5
  • City & ISP Targeting
  • Unlimited Threads
  • Rollover bandwidth

See How Clients Are Using Residential Proxies.

Influencer Marketing

Digital stores and brands are using our residential and mobile proxies to extract valuable influencers across social platforms to increase sales.

Ad Verification

Advertisers use ProxyEmpire's network to sniff out potential ad fraud. They use granular targeting to see their ads on all devices and locations.

Sneaker Proxies

Catch the latest sneaker drops and cop them quick with fast residential proxies that go undetected by all sneaker brand sites. 

SEO Monitoring

Check your SERP performance with GEO-specific targeting and spy on the competition without them knowing using your own crawler.

ProxyEmpire
Works With All Of Your Favorite Tools.

Learning Center