Exception: GitHub::API::AuthenticationFailedError Private

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

Overview

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

Error when authentication fails.

Instance Attribute Summary

Attributes inherited from Error

#github_message

Instance Method Summary collapse

Constructor Details

#initialize(credentials_type, github_message) ⇒ AuthenticationFailedError

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns a new instance of AuthenticationFailedError.



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'utils/github/api.rb', line 81

def initialize(credentials_type, github_message)
  @github_message = github_message
  message = "GitHub API Error: #{github_message}\n"
  message << case credentials_type
  when :github_cli_token
    <<~EOS
      Your GitHub CLI login session may be invalid.
      Refresh it with:
        gh auth login --hostname github.com
    EOS
  when :keychain_username_password
    <<~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
    EOS
  when :env_token
    require "utils/formatter"
    <<~EOS
      HOMEBREW_GITHUB_API_TOKEN may be invalid or expired; check:
        #{Formatter.url("https://github.com/settings/tokens")}
    EOS
  when :none
    NO_CREDENTIALS_MESSAGE
  end
  super message.freeze
end