Class: GitHub::AuthenticationFailedError

Inherits:
Error
  • Object
show all
Defined in:
Library/Homebrew/utils/github.rb

Instance Method Summary collapse

Constructor Details

#initialize(error) ⇒ AuthenticationFailedError

Returns a new instance of AuthenticationFailedError



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'Library/Homebrew/utils/github.rb', line 33

def initialize(error)
  message = "GitHub #{error}\n"
  if ENV["HOMEBREW_GITHUB_API_TOKEN"]
    message << <<~EOS
      HOMEBREW_GITHUB_API_TOKEN may be invalid or expired; check:
      #{Formatter.url("https://github.com/settings/tokens")}
    EOS
  else
    message << <<~EOS
      The GitHub credentials in the macOS keychain may be invalid.
      Clear them with:
        printf "protocol=https\\nhost=github.com\\n" | git credential-osxkeychain erase
      Or create a personal access token:
        #{ALL_SCOPES_URL}
      and then set the token as: export HOMEBREW_GITHUB_API_TOKEN="your_new_token"
    EOS
  end
  super message
end