module Octokit::Authentication

def application_authenticated?

Returns:
  • (Boolean) -

Other tags:
    See: https://developer.github.com/v3/#unauthenticated-rate-limited-requests -
def application_authenticated?
  !!(@client_id && @client_secret)
end

def basic_authenticated?

Returns:
  • (Boolean) -

Other tags:
    See: https://developer.github.com/v3/#authentication -
def basic_authenticated?
  !!(@login && @password)
end

def bearer_authenticated?

Returns:
  • (Boolean) -

Other tags:
    See: https://developer.github.com/early-access/integrations/authentication/#as-an-integration -
def bearer_authenticated?
  !!@bearer_token
end

def login_from_netrc

def login_from_netrc
  return unless netrc?
  require 'netrc'
  info = Netrc.read netrc_file
  netrc_host = URI.parse(api_endpoint).host
  creds = info[netrc_host]
  if creds.nil?
    # creds will be nil if there is no netrc for this end point
    octokit_warn "Error loading credentials from netrc file for #{api_endpoint}"
  else
    creds = creds.to_a
    self.login = creds.shift
    self.password = creds.shift
  end
rescue LoadError
  octokit_warn 'Please install netrc gem for .netrc support'
end

def token_authenticated?

Returns:
  • (Boolean) -

Other tags:
    See: https://developer.github.com/v3/#authentication -
def token_authenticated?
  !!@access_token
end

def user_authenticated?

Returns:
  • (Boolean) -

Other tags:
    See: https://developer.github.com/v3/#authentication -
def user_authenticated?
  basic_authenticated? || token_authenticated?
end