class

Octokit::Client

Inherits Octokit::Client::Deployments < Octokit::Client::Say < Octokit::Client::Statuses < Octokit::Client::Search < Octokit::Client::Releases < Octokit::Client::Organizations < Octokit::Client::Repositories < Octokit::Client::RateLimit < Octokit::Client::Users < Octokit::Client::PubSubHubbub < Octokit::Client::Markdown < Octokit::Client::Issues < Octokit::Client::Authorizations < Octokit::Warnable < Octokit::Preview < Octokit::Connection < Octokit::Authentication < Octokit::Configurable < Octokit::Authentication < Reference < Object

User client for interacting with the GitHub API.

The Client class is your main entrypoint into the GitHub user API. If you want to access the enterprise admin or enterprise management APIs, see EnterpriseAdminClient and EnterpriseManagementClient respectively.

Configuration: Configuration options for Client are stored in Configurable and include:

  • access_token : String
  • auto_paginate : Bool
  • bearer_token : String
  • client_id : String
  • client_secret : String
  • default_media_type : String
  • connection_options : Halite::Options
  • middleware : Array(Halite::Feature)
  • per_page : Int32
  • proxy : String
  • ssl_verify_mode : Int32
  • user_agent : String

The following items are setters only:

  • api_endpoint : String
  • login : String
  • password : String
  • web_endpoint : String

Defaults for these are stored in Default. Most can be set using environment variables.

Examples:

With standard auth:

@client = Octokit::Client.new("monalisa", "PASSWORD")

With access token:

@client = Octokit::Client.new("monalisa", access_token: "ACCESS_TOKEN")

With bearer token:

@client = Octokit::Client.new("monalisa", bearer_token: "BEARER_TOKEN")

Constants

CONVENIENCE_HEADERS = Set {"accept", "content_type"}

Constructors

new(login : String | Nil = nil, password : String | Nil = nil, access_token : String | Nil = nil, bearer_token : String | Nil = nil, client_id : String | Nil = nil, client_secret : String | Nil = nil)

Create a new Client instance.

Example:

cli = Octokit::Client.new("monalisa", "MY_PASSWORD")
pp cli.user # Show information about the logged in user
Source
new(login : String | Nil = nil, password : String | Nil = nil, access_token : String | Nil = nil, bearer_token : String | Nil = nil, client_id : String | Nil = nil, client_secret : String | Nil = nil, &)

Create a new Client instance yielding a block.

Example:

Octokit::Client.new("monalisa", "MY_PASSWORD") do |cli|
  pp cli.user # Show information about the logged in user
end
Source

Instance methods

access_token=(value : String)

Set OAuth access token for authentication

Source
as_app(key = @client_id, secret = @client_secret, &)
Source
bearer_token=(value : String)

Set Bearer Token for authentication

Source
client_id=(value : String)

Set OAuth app client_id

Source
client_secret=(value : String)

Set OAuth app client_secret

Source
client_without_redirects(options = {} of String => String)
Source
ensure_basic_authenticated!
Source
ensure_token_authenticated!
Source
inspect

Text representation of the client, masking tokens and passwords

Source
login=(value : String)

Set username for authentication

Source
password=(value : String)

Set password for authentication

Source

Nested types