Advertisement
dereksir

Untitled

Apr 29th, 2024
586
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.54 KB | None | 0 0
  1. // create a OkHttpClient builder instance and configure it to use the proxy
  2. OkHttpClient client = new OkHttpClient.Builder()
  3.     .proxy(proxy)
  4.     .authenticator(new Authenticator() {
  5.         @Override
  6.         public Request authenticate(Route route, Response response) throws IOException {
  7.             // If the proxy requires authentication, provide the credentials
  8.             String credential = Credentials.basic(proxyUsername, proxyPassword);
  9.             return response.request().newBuilder()
  10.                 .header("Proxy-Authorization", credential)
  11.                 .build()
  12.             }
  13.         })
  14.         .build();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement