mapbox / mapbox-java

The Mapbox Java SDK – Java wrappers around Mapbox APIs and other location data
https://docs.mapbox.com/android/java/overview/
MIT License
424 stars 120 forks source link

Unable to download from private repository with Maven #1494

Closed doompadee closed 1 year ago

doompadee commented 2 years ago

Trying to consume the latest Mapbox Java API with Maven 3.8.6 fails due to missing authorization:

[DEBUG] Repositories (dependencies): [central (https://repo1.maven.org/maven2/, default, releases+snapshots), mapbox (https://api.mapbox.com/downloads/v2/releases/maven, default, releases+snapshots)]
[DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for https://api.mapbox.com/downloads/v2/releases/maven with username=mapbox, password=***
[ERROR] Failed to execute goal on project test: Could not resolve dependencies for project test:test:jar:0.0.1-SNAPSHOT: Failed to collect dependencies at com.mapbox.mapboxsdk:mapbox-sdk-services:jar:6.4.0: Failed to read artifact descriptor for com.mapbox.mapboxsdk:mapbox-sdk-services:jar:6.4.0: Could not transfer artifact com.mapbox.mapboxsdk:mapbox-sdk-services:pom:6.4.0 from/to mapbox (https://api.mapbox.com/downloads/v2/releases/maven): authentication failed for https://api.mapbox.com/downloads/v2/releases/maven/com/mapbox/mapboxsdk/mapbox-sdk-services/6.4.0/mapbox-sdk-services-6.4.0.pom, status: 401 Unauthorized -> [Help 1]

I've tried to match the steps outlined for Gradle: https://docs.mapbox.com/android/maps/guides/install/

Is this a known problem with Maven? Any workaround?

shellta commented 1 year ago

hi, @doompadee

try this,

<servers>
    <server>
        <id>mapbox</id>
        <configuration>
            <httpHeaders>
                <property>
                    <name>Authorization</name>
                    <!-- Base64-encoded "mapbox:token" -->
                    <value>Basic bWFwYm94OnRva2Vu</value>
                </property>
            </httpHeaders>
        </configuration>
    </server>
</servers>
doompadee commented 1 year ago

Great! It builds fine now. Thanks much for your help.