Support Custom HTTP Client (Proxy) in MSAL Android for P2P Bootstrap Connectivity
I'm developing an Android app that uses the Wi‑Fi Bootstrap API to establish a persistent peer-to-peer (P2P) connection to a specific device. This connection is essential to the app's functionality, but the API explicitly does not provide internet access. As a result, when connected to the P2P network, MSAL fails to refresh access tokens because it cannot reach the required endpoints.
We cannot use the Wi‑Fi Suggestion API because it doesn’t guarantee a direct connection. The only viable solution is to route MSAL network traffic through a proxy running on the connected device.
Currently, the MSAL Android library appears to ignore the system or default proxy settings, which prevents us from routing requests through this proxy.
What I’m requesting is either:
- MSAL Android should respect the system proxy settings used by the
HttpURLConnection
orHttpClient
it internally uses. - Or, provide a supported way to configure proxy usage for internal MSAL network traffic—without needing to inject a fully custom
HttpClient
.
I’m aware that .NET MSAL allows proxy configuration through a custom HTTP client, but Android developers currently have no reliable mechanism to achieve the same outcome.
Workarounds I’ve tried:
- Using
URL.setURLStreamHandlerFactory()
to intercept and forward requests through the proxy — this is fragile and unsafe in apps using multiple libraries. - Attempting to override
SSLSocketFactory
via reflection — also unsuccessful and risky. - I also tried setting system properties for proxies, but MSAL still bypasses them.
This limitation effectively blocks MSAL use in apps that rely on Wi‑Fi P2P without external internet.
Questions:
- Can MSAL Android be updated to respect system-wide proxy settings?
- If not, is there any supported or recommended approach to route MSAL token requests through a local proxy?
- Is there any plan to support proxy configuration in the MSAL Android SDK?
This feature would greatly improve MSAL's support for constrained networking environments like IoT and local-only mesh networks.
Below are the Github issues ive created which haven't gotten a single response from the developers.
- https://github.com/AzureAD/microsoft-authentication-library-for-android/issues/2297
- https://github.com/AzureAD/microsoft-authentication-library-common-for-android/pull/2650
- https://github.com/AzureAD/microsoft-authentication-library-common-for-android/issues/2661
If i should ask this question somewhere else please let me know where since i have no clue where i can ask for features like this and get some actual feedback