urbanairship / java-library

Java client library for the Urban Airship API
Other
32 stars 40 forks source link

No way to add custom headers to UrbanAirshipClient #102

Open zhe-zhao opened 1 year ago

zhe-zhao commented 1 year ago

Issue statement

I am integrating to Airship platform behind an API proxy running in application layer. Hence have the need to add additional request headers to pass the proxy server authentication.

Didn't find a proper way of doing so as the UrbanAirshipClient always:

  1. Pick up headers from request.getRequestHeaders()
  2. Override Authorization header and X-UA-Appkey header value based on client config.

https://github.com/urbanairship/java-library/blob/5c0c7d20fda10b7077bdfa6f16178de4aea270be/src/main/java/com/urbanairship/api/client/UrbanAirshipClient.java#L79-L107

Feature request

Accept custom headers in the Client Builder class. So that one can easily pass through proxies & firewalls

martin-vct commented 1 year ago

Hi @zhe-zhao,

We have well noted your request about accepting custom headers. We'll check internally if this could be added in future updates.

In the meantime, I wanted to let you know we still have a way to setup the Client with Proxy: https://docs.airship.com/api/libraries/java/#configuration

Realm realm = new Realm.Builder("user", "password")
    .setScheme(Realm.AuthScheme.BASIC)
    .build();

ProxyServer proxyServer = new ProxyServer.Builder("test.urbanairship.com", 8080)
    .setRealm(realm)
    .build();

AsyncRequestClient asyncRequestClient = AsyncRequestClient.newBuilder()
    .setProxyServer(proxyServer)
    .build();

UrbanAirshipClient client = UrbanAirshipClient.newBuilder()
    .setKey("key")
    .setSecret("secret")
    .setClient(asyncRequestClient)
    .build();