Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to download from private repository with Maven #1494

Closed
doompadee opened this issue Sep 9, 2022 · 2 comments
Closed

Unable to download from private repository with Maven #1494

doompadee opened this issue Sep 9, 2022 · 2 comments

Comments

@doompadee
Copy link

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/

  • Added the repository in the POM:
    <repositories>
      [...]
      <repository>
        <id>mapbox</id>
        <name>Mapbox</name>
        <url>https://api.mapbox.com/downloads/v2/releases/maven</url>
      </repository>
    </repositories>
    
  • Created a private token with Download:READ permission
  • Provided the token through the ~/.m2/settings.xml file:
    <settings>
     <servers>
      <server>
       <id>mapbox</id>
       <username>mapbox</username>
       <password>TOKEN</password>
      </server>
     </servers>
    </settings>
    
    

Is this a known problem with Maven? Any workaround?

@shellta
Copy link

shellta commented Nov 22, 2022

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants