123456789_123456789_123456789_123456789_123456789_

Module: Octokit::Authentication

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Included In:
Defined in: lib/octokit/authentication.rb

Overview

Authentication methods for Client

Constant Summary

Instance Attribute Summary

Instance Method Summary

Instance Attribute Details

#application_authenticated?Boolean (readonly)

Indicates if the client has OAuth Application client_id and secret credentials to make anonymous requests at a higher rate limit

[ GitHub ]

  
# File 'lib/octokit/authentication.rb', line 55

def application_authenticated?
  !!(@client_id && @client_secret)
end

#basic_authenticated?Boolean (readonly)

Indicates if the client was supplied Basic Auth username and password

[ GitHub ]

  
# File 'lib/octokit/authentication.rb', line 19

def basic_authenticated?
  !!(@login && @password)
end

#bearer_authenticated?Boolean (readonly)

Indicates if the client was supplied a bearer token

[ GitHub ]

  
# File 'lib/octokit/authentication.rb', line 36

def bearer_authenticated?
  !!@bearer_token
end

#token_authenticated?Boolean (readonly)

Indicates if the client was supplied an OAuth access token

[ GitHub ]

  
# File 'lib/octokit/authentication.rb', line 28

def token_authenticated?
  !!@access_token
end

#user_authenticated?Boolean (readonly)

Indicates if the client was supplied an OAuth access token or Basic Auth username and password

[ GitHub ]

  
# File 'lib/octokit/authentication.rb', line 45

def user_authenticated?
  basic_authenticated? || token_authenticated?
end

Instance Method Details

#login_from_netrc (private)

[ GitHub ]

  
# File 'lib/octokit/authentication.rb', line 61

def 
  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. = creds.shift
    self.password = creds.shift
  end
rescue LoadError
  octokit_warn 'Please install netrc gem for .netrc support'
end