Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // create a OkHttpClient builder instance and configure it to use the proxy
- OkHttpClient client = new OkHttpClient.Builder()
- .proxy(proxy)
- .authenticator(new Authenticator() {
- @Override
- public Request authenticate(Route route, Response response) throws IOException {
- // If the proxy requires authentication, provide the credentials
- String credential = Credentials.basic(proxyUsername, proxyPassword);
- return response.request().newBuilder()
- .header("Proxy-Authorization", credential)
- .build()
- }
- })
- .build();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement