Greg Briggs
Greg Briggs

Reputation: 11

ADO Artifacts Scoped NPM Install 401 Error Using Mac

I have an artifact on ADO with published package @foo/bar

I followed the install instruction with

  1. one user .npmrc containing links, usernames, base-64 encoded pat token generated by ADO "install package" documentation, filling in the requisite fields

    ; begin auth token
    //pkgs.dev.azure.com/[org name]/[project id]/_packaging/[artifact feed name]/npm/registry/:username=[username]
    //pkgs.dev.azure.com/[org name]/[project id]/_packaging/[artifact feed name]/npm/registry/:_password=[BASE64_ENCODED_PERSONAL_ACCESS_TOKEN]
    //pkgs.dev.azure.com/[org name]/[project id]/_packaging/[artifact feed name]/npm/registry/:email=[email]
    //pkgs.dev.azure.com/[org name]/[project id]/_packaging/[artifact feed name]/npm/:username=[username]
    //pkgs.dev.azure.com/[org name]/[project id]/_packaging/[artifact feed name]/npm/:_password=[BASE64_ENCODED_PERSONAL_ACCESS_TOKEN]
    //pkgs.dev.azure.com/[org name]/[project id]/_packaging/[artifact feed name]/npm/:email=[email]
    ; end auth token
    
  2. one package - based .npmrc file containing the scope-prefaced registry

    @foo:registry=https://pkgs.dev.azure.com...
    always-auth=true
    
  3. I cloned project 'baz', cd'd into the directory and ran `npm install @foo/bar

Received 401 unauthorized when trying to install the package

I was expecting the package @foo/bar to be installed and listed in the package.json file

I tried:

  1. Adding a scope to the user-level .npmrc
  2. surrounding the base-64 auth token in quotes/brackets "[base-64-pat-token]"
  3. regenerating the pat token
  4. authenticating using `npm login --source @foo
    1. This resulted in infinite spinning with a masking of the project id on the cli due to auth policies preventing web-based access
  5. iterating on scope and registry.
    1. removed the scope altogether has the same result of 401
    2. logging in w/out --source resulted in the same as trying to login with --source when the source was included

Upvotes: 1

Views: 23

Answers (1)

Bright Ran-MSFT
Bright Ran-MSFT

Reputation: 13944

To restore (read) packages from an Azure Artifacts feed, you need to check if you have the following permissions:

  1. Since the Artifacts feed is project-scoped, ensure you have been added as a member of the corresponding project so that you have at least the Reader role permission in the project.

  2. In the Artifacts feed, go to "Feed Settings" > "Permissions", ensure you (or the group where you are a member) have at least the Feed Reader role assigned.

    enter image description here

  3. When you create/edit a PAT (Personal Access Token) for accessing the Artifacts feed, ensure the PAT has at least Packaging (Read) scope.

    enter image description here

  4. Then you can following steps mentioned in "Connect your npm project to Azure Artifacts" to configure the project .npmrc and user .npmrc.


Upvotes: 0

Related Questions