OkHTTPClient Proxy authentication how to? : <p><strong>Question:</strong> How do I add a authorization proxy to OkHTTP.</p>

<p>I know that OkHTTP's builder <a href="http://square.github.io/okhttp/3.x/okhttp/" rel="noreferrer">does support proxies</a> although I am having a hard time setting one up.</p>

<pre><code>/**
 * Given a Url and a base64 encoded password return the contents of a website.
 * @param urlString
 * @param password
 * @return JSON
 */
public String getURLJson(String urlString, String password) {       
        OkHttpClient client = new OkHttpClient.Builder()
                .connectTimeout(60, TimeUnit.SECONDS)
                .writeTimeout(60, TimeUnit.SECONDS)
                .readTimeout(60, TimeUnit.SECONDS)
                .build();

        Request request = new Request.Builder()
          .url(urlString)
          .get()
          .addHeader("authorization", "Basic " + password)
          .addHeader("cache-control", "no-cache")
          .build();

        Response response = null;
        try {
            response = client.newCall(request).execute();
            String string = response.body().string();
            response.body().close();
            return string;
        } catch (IOException e) {
            System.err.println("Failed scraping");
            e.printStackTrace();
        }
        return "failed";
    }
</code></pre>

<p>I have the IP / port / username / password. </p>

<p>Although I do not know how to turn those into a <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/reflect/Proxy.html" rel="noreferrer"><code>Proxy proxy</code></a> which can then be used in client.SetProxy().</p>

<p>It seems overly complicated and I simply can't seem to figure it out. Any help would be appreciated.</p>
