Unauthorized when publishing private Package with Personal Access Token #45097
-
I am having an issue with publishing my private Node.js GitHub Packages using Personal access tokens (classic). I am receiving the following error in GitHub Actions publish-gpr:
I have updated the personal access token several times with the same scope settings of repo and Despite this, I am still receiving the above error when trying to create a new release. The token is not expired and is correct without typos. It is present in GitHub .npmrc:
.github\workflows\release-package.yml:
and I have tried:
package.json:
Can anyone provide guidance on how to resolve this issue? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 10 replies
-
Did you follow the instructions at https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry#authenticating-with-a-personal-access-token? Can you send your |
Beta Was this translation helpful? Give feedback.
-
Following Quickstart for GitHub Packages on a private repo I also had that error message. name: Node.js Package
on:
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- run: npm ci
- run: npm test
publish-gpr:
needs: build
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://npm.pkg.github.com/
- run: npm ci
- run: |
echo "@username:registry=https://npm.pkg.github.com" >> .npmrc
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" >> .npmrc
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} This solved it from me. |
Beta Was this translation helpful? Give feedback.
-
What worked for me is moving env declaration to the job level:
|
Beta Was this translation helpful? Give feedback.
-
I solved it by changing where GITHUB_TOKEN is your env variable |
Beta Was this translation helpful? Give feedback.
Following Quickstart for GitHub Packages on a private repo I also had that error message.
I've solved it to remove the
.npmrc
from the repo and build it into the gh actions yaml end let_authToken
use the providedsecrets.GITHUB_TOKEN
.