mapbox-navigation-android
mapbox-navigation-android copied to clipboard
RouteOptions.baseUrl not respecting Basic Authentication credentials in URL
**Android API: 31 ** Mapbox Navigation SDK version: 2.3.0
Steps to trigger behavior
Here's a minimal example, allthough the real usecase for having a Basic Authentication is different. It uses Docker to simulate a web server running locally with a proxy pass to Mapbox's API and an Android Emulator running on the same machine.
-
Setup a nginx-Docker with Basic Authentication for "location /" and a pass through proxy to Mapbox
location / { auth_basic "Protected Area"; auth_basic_user_file /var/htpasswd; proxy_pass https://api.mapbox.com; }
-
Content of /var/htpasswd is
user:$apr1$0lk63gex$zT8La3WSbV1NWY/JOQiOE1
That is both "user" for username and password -
Following the instructions to create a workin Android Demo using version 2.3.0 of Mapbox Navigation SDK for Android and add the following baseUrl when requesting routes
.baseUrl("http://user:[email protected]")
. When running on Android Emulator 10.0.2.2 points to the localhost of the host (e.g. the machine that also runs the nginx docker) -
Enable logging via
.isDebugLoggingEnabled(true)
when creating MapboxNavigationProvider
Expected behavior
A successful route description from Mapbox as if baseUrl was not set.
Actual behavior
Getting a 401 from Nginx. From the Mapbox Navigation SDK Logs:
Directions Service: Get route response: <html> <head><title>401 Authorization Required</title></head> <body> <center><h1>401 Authorization Required</h1></center> <hr><center>nginx/1.21.6</center> </body> </html> with code 401