Skip to content
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
Cannot retrieve contributors at this time
layout title date categories post_photo
Using an HTTP proxy on Play Framework's WSClient
2021-01-10 20:35:32 -0700

If you ever had the need to use http proxies from your JVM-based apps, you likely faced the pain involved with the Java Authenticator. Gladly, Play Framework's WSClient has a cleaner way/

Instead of polluting the global scope with custom authenticators, you just need to create an instance of, which can be set to every request while using the WSClient, like this:

import{DefaultWSProxyServer, WSClient}

val proxy = DefaultWSProxyServer(
  host = "", // no protocol on purpose
  port = 8000,
  principal = Some(username), // needed if basic-authentication is required
  password = Some(password), // needed if basic-authentication is required
  protocol = Some("https")

def f(ws: WSClient) = {

That's it, far simpler than dealing with the Java way.