"401 Content access is protected by token" authentication failure while performing maven release - Central Repository - Sonatype Community

401 Content access is protected by token authentication failure while performing maven release

I am getting a “401 Content access is protected by token” authentication failure while performing maven release. But I did not make any changes regarding Sonatype/Nexus.

[ERROR] Failed to execute goal org.sonatype.plugins:nexus-staging-maven-plugin:1.6.8:deploy (injected-nexus-deploy) on project manifold-all: Remote staging failed: Failed to deploy artifacts: Could not transfer artifact systems.manifold:manifold-tuple-rt:jar.asc:javadoc:2024.1.19 from/to ossrh (https://oss.sonatype.org:443/service/local/staging/deployByRepositoryId/systemsmanifold-1279): authentication failed for https://oss.sonatype.org:443/service/local/staging/deployByRepositoryId/systemsmanifold-1279/systems/manifold/manifold-tuple-rt/2024.1.19/manifold-tuple-rt-2024.1.19-javadoc.jar.asc, status: 401 Content access is protected by token

This is my own FOSS repo and I’m not doing anything special. I released the prior version a few days ago with no problems. And reading this it appears this “protected by token” feature can only be set in Sonatype Nexus Repository software, which I do not have or use.

Not sure how this could happen without my making changes via Sonatype/Nexus. Any ideas?

Sonatype won’t help me because I’m not a paying customer. Thanks.


Responses

post by rsmckinney on Jun 17, 2024

I’m having the exact same issue. FOSS project that can no longer be published with our existing credentials, and no way to configure User Tokens.

post by mben-soula on Jun 18, 2024

We’ve recently made necessary changes to our account management system that involves requiring a user token to publish. Although we attempted to reach out to all of our publishers before this change, we realize that the communication might not have reached you. Please follow the instructions on publishing via a user token in order to resolve this issue.

Please keep in mind that the user tokens generated in Central Portal cannot be used in OSSRH. Additionally, if you need to reset your OSSRH password, please follow these instructions to manage your credentials.

post by bitspittle on Jun 18, 2024

I ran into this as well. The instructions from @mben-soula worked for me:

  1. Go to https://s01.oss.sonatype.org/
  2. Go to profile
  3. Change the pulldown from “Summary” to “User Token”
  4. Click on “Access User Token”

I am using Gradle in my project, so I have all my credentials stored in a private gradle.properties file. Using the username and password values from the “Access User Token” popup, I created two new entries:

ossrhToken=...
ossrhTokenPassword=...

And finally, I updated my Gradle build script, it should look something like this:

maven {
    credentials {
        username = findProperty("ossrhToken") as String
        password = findProperty("ossrhTokenPassword") as String
    }
}

post by bthomas on Jun 19, 2024

Same here. Thanks for the question @rmckinley.

post by robfletcher on Jun 19, 2024

I have an existing project that publishes to oss.sonatype.org. I’ve accessed my token, stored it in my private gradle.properties, and replaced my old username / password configuration with:

maven {
    name = "nexus"
    url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
    credentials {
        username = findProperty("ossrhToken") as String
        password = findProperty("ossrhTokenPassword") as String
    }
}

but I still get Received status code 401 from server: Content access is protected by token. I don’t understand what I’m missing.

post by yegor256 on Jun 24, 2024

I’m experiencing the same problem. The token has been created, the settings.xml file has been updated, but I’m getting “401 - Unauthorized” reply from the server. What’s my next step?

post by zenglb on Jun 25, 2024

Can you tell me more info about where to insert this code in Gradle file? My Android studio Project implementation ‘com.vanniktech.maven.publish.base:com.vanniktech.maven.publish.base.gradle.plugin:0.25.3’.

post by cjbooms on Jul 5, 2024

Just tried one last time and it worked with a new set of credentials. I must’ve cycled through about 5 sets before it worked.

post by yidun on Jul 8, 2024

I also encountered this problem. I tried generating a user token multiple times and configured it properly, but keep getting 401. I finally made it work by upgrading my maven version to 3.9.8, maybe it also suits your situation.