AuthToken Publish issue

I was trying to publish app to our internal Nexus repo (PRO 3.46.0-01) from our GitLab pipeline job. I created the publish token from the Nexus UI (base64 encoded user: base64 encoded password) But I got this error:

*npm notice Publishing to https:///repository/gitlab/ with tag latest and default access npm http fetch PUT 401 https:///repository/gitlab/reference-app 629ms npm verb stack HttpErrorAuthUnknown: Unable to authenticate, need: BASIC realm=“Sonatype Nexus Repository Manager” *

As part of my debugging, i changed the code from
"npm config set ${npm_publish_registry_host_and_path}:**_authToken**" "${NPM_PUBLISH_TOKEN}"

" npm config set "${npm_publish_registry_host_and_path}:**_auth**" "${NPM_PUBLISH_TOKEN}"" and it started working.

Please note that “NPM Bearer Token Realm” is enabled in our Nexus.

Is there anything wrong in the way Token generated ?(User Tokens)

For Pro you can file a support ticket.

I believe your issue here is that those User Tokens would be used as an alternative for Basic Auth headers rather than an npm Token. If you’re looking to get a token for npm you’d want to use npm login (you could also use the user/password from the User Token rather than the real username & password)