NuGet package publishing using API key - Sonatype Nexus Repository - Sonatype Community
NuGet package publishing using API key
post by Vilius_Sumskas on Aug 4, 2025
I’m trying to setup NuGet package repository on Community Edition. Documentation here NuGet Repositories implies that it is possible to use API key as a ClearTextPassword field for publishing, however no matter what I try this doesn’t work. Repository Manager always returns 401. If I try a user password instead, everything starts to work. If I use the same API key in my main nuget.config file by setting it via nuget setapikey it also works. Just not when the key is used as a clear text environment variable.
I have also found this older post Authenticating to NuGet Hosted Repo with Tokens which vaguely confirms that API key for NuGet publishing should work, but doesn’t say in which configuration.
Is this a mistake in the documentation and I must always use nuget setapikey or am I doing something wrong? I’m now starting to think that’s documentation issue because here NuGet Repositories the variable is named NEXUS_PASSWORD which doesn’t match %NEXUS_API_KEY% in the example configuration above.
post by mpiggott on Aug 5, 2025
Have you enabled the realm as described in the help documentation? NuGet Repositories (link should go to the subsection)
post by Vilius_Sumskas on Aug 6, 2025
Yes, the realm is enabled. As I said, the API key works in a context of <apiKeys> nuget.config configuration option, but doesn’t work “in place” of a password, like documentation suggest it should.
post by Vilius_Sumskas on Aug 25, 2025
Any more ideas?