Npm ERR! Unable to authenticate, need: BASIC realm

We are evaluating Nexus Repository Manager 3 and have our users logging in via SAML Authentication. We have a private NPM repository and need to authenticate our users to it using NPM. I have added the npm Bearer Token Realm to the Realms in Administration and enabled user Tokens. I have then followed the guide here,

https://help.sonatype.com/repomanager3/nexus-repository-administration/formats/npm-registry/npm-security

On setting up NPM. After following the guide I received the following error,

npm ERR! code ERR_INVALID_AUTH
npm ERR! Invalid auth configuration found: _auth must be renamed to //nexu.local/nexus/repository/npm-group/:_auth in user config
npm ERR! Please run npm config fix to repair your configuration.`

I ran npm config fix as instructed and it seemed to move the _auth from it’s own line and appended it on our private registry link. Then when turning off Anonymous access and running npm install I get the following error,

npm ERR! code E401
npm ERR! Unable to authenticate, need: BASIC realm=“Sonatype Nexus Repository Manager”

Could you assist in how we move forward? My .npmrc file looks like this,

registry=https://nexus.local/nexus/repository/npm-group/
always-auth=true
email=my.email
//nexus.local/nexus/repository/npm-group/:_auth=“BASE64 VALUE FROM NEXUS USER TOKEN”

We are able to install from the npm-group repository when anonymous access is enabled, just not when requiring authentication.

Nexus PRO 3.61.0-02

Thank you
Chad

Hi @chad.dalton and welcome! I spoke to someone internally who recommended recreating your .npmrc file. They also recommended ensuring the correct realms were enabled and permissions were correctly set. I hope that does the trick for you!

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)