mapbox-navigation-android icon indicating copy to clipboard operation
mapbox-navigation-android copied to clipboard

RouteOptions.baseUrl not respecting Basic Authentication credentials in URL

Open LSBOSS opened this issue 2 years ago • 0 comments

**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.

  1. 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; }

  2. Content of /var/htpasswd is user:$apr1$0lk63gex$zT8La3WSbV1NWY/JOQiOE1 That is both "user" for username and password

  3. 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)

  4. 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

LSBOSS avatar Mar 04 '22 10:03 LSBOSS