티스토리 뷰

Warning

Warning: Error searching on GitHub: GitHub API Error: Bad credentials
The GitHub credentials in the macOS keychain may be invalid.
Clear them with:
  printf "protocol=https\nhost=github.com\n" | git credential-osxkeychain erase
Create a GitHub personal access token:
    https://github.com/settings/tokens/new?scopes=gist,public_repo,workflow&description=Homebrew
  echo 'export HOMEBREW_GITHUB_API_TOKEN=your_token_here' >> ~/.zshrc

평상시처럼 Homebrew를 사용하여 search 명령어를 사용하였더니 위와 같은 경고 문구가 나타났습니다. 해당하는 정보들은 무리 없이 출력되었으나 서두에 나오는 경고 문구를 해결하기 위해 알아보기 시작하였습니다.

Warning: Error searching on GitHub: GitHub API Error: Bad credentials
The GitHub credentials in the macOS keychain may be invalid.

다음 문구에서 GitHub API가 에러가 발생했는데 증명이 되지 않는다. GitHub 증명에 관련된 masOS의 키체인이 유효하지 않은 것 같다라고 합니다.

키체인 그리고 토큰이라고 해서 2021.07.05 Github로부터 메일이 하나 왔던 것이 생각나 메일에서 명시한 링크를 타고 들어가보니 github에서 자사 블로그를 통해 공지한 사항이 보였습니다.

In July 2020, we announced our intent to require the use of token-based authentication (for example, a personal access, OAuth, or GitHub App installation token) for all authenticated Git operations. Beginning August 13, 2021, we will no longer accept account passwords when authenticating Git operations on GitHub.com.

GitHub 블로그에서 공지한 내용은 2021.08.13 일자로 git 관련 작업을 할 경우 계정 암호를 사용하지 않고 토큰을 기반으로 사용한다는 것이었습니다.

그리고 전에 2021.08.14 일에 만들어 놓은 personal access token이 만료가 되었다는 것을 깨닫고

Clear them with:
  printf "protocol=https\nhost=github.com\n" | git credential-osxkeychain erase
Create a GitHub personal access token:
    https://github.com/settings/tokens/new?scopes=gist,public_repo,workflow&description=Homebrew
  echo 'export HOMEBREW_GITHUB_API_TOKEN=your_token_here' >> ~/.zshrc

위 경고문구에서 지향하는 메뉴얼대로 진행하여 Homebrew 토큰을 따로 설정하는 것이 아닌 기존에 있던 personal access token의 기간을 갱신하면 되겠다고 생각했습니다.

Github 접속 및 로그인

Settings 접근

GitHub 에 들어간 후 로그인을 하고 우측 상단의 빨간색 네모 박스 아이콘을 클릭한 후 Setting을 클릭합니다.

Developer Settings 접근

그 후 Developer settings를 클릭합니다.

Personal access tokens -> Generate new token

Personal access tokens를 클릭한 후 Generate new token을 클릭합니다.

Access token 생성

Note에 자신이 원하는 토큰의 명칭을 적고, Expiration 즉 만료기간을 7, 30, 60, 90 등의 기간으로 설정합니다. repo, workflow, gist 항목을 체크 한 후 Generate token을 클릭하여 토큰을 생성합니다.

Warning: Error searching on GitHub: GitHub API Error: Bad credentials
The GitHub credentials in the macOS keychain may be invalid.
Clear them with:
  printf "protocol=https\nhost=github.com\n" | git credential-osxkeychain erase
Create a GitHub personal access token:
    https://github.com/settings/tokens/new?scopes=gist,public_repo,workflow&description=Homebrew
  echo 'export HOMEBREW_GITHUB_API_TOKEN=your_token_here' >> ~/.zshrc

물론 Homebrew에서 경고한 문구에서

https://github.com/settings/tokens/new?scopes=gist,public_repo,workflow&description=Homebrew

이 주소를 들어가도 똑같이 설정을 할 수 있습니다.

Token 복사 및 기억하기

다음과 같이 토큰이 생성이 됩니다. 이 토큰 값은 초기 생성하였을 경우에만 값이 나타나고 그 후 접속하였을 경우 제가 평상시 사용하고 있는 defaultToken 처럼 나타나지 않습니다. 그러므로 토큰 값을 복사하여 자신의 메모장 같은 기억하기 쉬운 곳에 붙여넣기하여 기억합니다.

다시 접속하였을 경우 토큰 값이 나타나지 않는 것을 알 수 있습니다.

github.com 키체인 수정

키체인 접근 애플리케이션 실행

macOS 기준입니다.

macOS 기본 어플인 키체인 접근 애플리케이션을 실행합니다.

github.com 항목 접근

github를 검색한 후 이름은 github.com이고 종류는 인터넷 암호이며 키체인은 로그인으로 된 항목을 클릭합니다.

암호 보기 체크 상자 설정

암호 보기 항목을 체크한 후 암호를 입력하여 허용 버튼 클릭합니다.

Token 입력 후 저장

Token 을 입력한 후 변경사항 저장 버튼을 클릭합니다.

Result

다시 brew search zsh 입력해보니 경고 문구가 뜨지 않고 깔끔하게 출력되는 것을 확인할 수 있습니다.

댓글