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.
Change the pulldown from “Summary” to “User Token”
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, shoud look something like this:
maven {
credentials {
username = findProperty("ossrhToken") as String
password = findProperty("ossrhTokenPassword") as String
}
}
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.
Do I need to start publishing via s01.oss.sonatype.org? I don’t have account credentials there and my understanding was existing projects keep using the original server.
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?
Got the same issue, and creating a user token got me to the same situation as for @yegor256 (Hi Egor, I’ve read your book once!) - getting 401 - Unauthorized. For some reason recreating a user token for the second time fixed the issue for me.
I solved this problem by making sure my token is created at oss.sonatype.org and I deploy to the same server (mentioning it in settings.xml). Apparently, there are many servers and you can create tokens at each one of them. Apparently, the tokens won’t work on other servers.
Can every one guide me the username and passwod to access nexus repository manager because I use the same username and password in maven central repository but it not match. https://oss.sonatype.org/
We had same “401 content access is protected by token”. First did not work after generating user token. We tried “Reset User Token” button (under the “Access User Token” button), and generating a new one via “Access User Token” button. Plus we pressed explicit “Close” button after generating in the popup containing the credentials (instead of letting it automatic close after 1 minute). After this we could upload artifacts again with these new user token credentials, so seems either the “reset” or the “explicit close” fixed it. Maybe this helps others.
+1 had the same issue. Resetting the token value fixed it. Token worked for several releases of our library (most recently June 21), but then failed with the next release on July 3. Reset the token values July 5 and retried the release and it succeeded
Also hit by this issue. I cannot get this to work for https://s01.oss.sonatype.org/, I have done the UserToken reset dance multiple times now to no avail.
Here is how I am passing it into my gradle setup, via Github Actions ENV variables.
I also encountered this problem. I tried generate user token multiple times and configed it properly, but keep getting 401. I finally make it work by upgrade my maven version to 3.9.8, maybe it also suits your situation.