Invalid authentication (as an unknown user)

Yeshin Lee
3 min readDec 25, 2023

TL;DR

  • Github PAT(Personal Access Token)이 만료되어 나타나는 에러다.
  • PAT을 새로 발급받아 Home에 있는 ./yarnrc.ymlnpmAuthToken에 넣는다.
  • 작업할 프로젝트에서 yarn을 실행했을 때, 해당 프로젝트에 추가된 다른 패키지에서 ‘Invalid authentication (as an unknown user)’ 에러가 발생했다.
  • ‘잘못된 인증(모르는 사용자)’ 의미로 보아, PAT(Personal Access Token)과 관련 있음을 예상할 수 있다.
  • 생각해보니 최근에 PAT 유효기간이 만료되었다는 알림을 받고 새로 발급받았던 기억이 났다.

PAT(Personal Access Token)이란?
password when authenticating to GitHub in the command line or with the API.

  1. Github 개인 프로필 SettingsDeveloper SettingsPersonal Access TokenPersonal access tokens 을 차례로 클릭한다.
  2. Beta 버전도 있지만, 안정적인 Tokens(classic)를 클릭한다.
  3. Note와 Expiration(token 만료일)을 입력한다.
  4. scope는 repo, write: packages, read:packages, delete:packages 를 모두 체크한다.

PAT은 발급 당시에만 확인할 수 있으므로 다른 곳에 저장해놔야 한다.

  1. Home directory에 ./yarnrc.yml 파일을 생성한다.
  2. 아래와 같이 npmAuthToken에 아까 만들었던 PAT을 넣고 저장한다.
$ vi ./yarnrc.yml
npmScopes:
{COMPANY_NAME}:
npmPublishRegistry: <https://npm.pkg.github.com>
npmRegistryServer: <https://npm.pkg.github.com>
npmAlwaysAuth: true
npmAuthToken: {GITHUB_TOKEN_HERE}
  • 해당 프로젝트에서 다시 yarn을 실행하면 해당 에러가 보이지 않는다.

에러를 볼 때마다 느끼지만 에러 메시지에 답이 있다.

--

--