Module: GitHub::Client::OAuth

Included in:
GitHub::Client
Defined in:
lib/github_api_v3/client/oauth.rb

Overview

Methods for the Authorizations API.

These methods require the user to use basic authentication.

Instance Method Summary collapse

Instance Method Details

#authorization(id) ⇒ Hash

Get a single authorization.

Requires basic authentication.

Examples:

client = GitHub.client(:login => 'username', :password => 'password')
client.authorization(12345)

Parameters:

  • id (Integer)

    The ID of the authorization to retrieve.

Returns:

  • (Hash)

    The authorization information.

See Also:



34
35
36
# File 'lib/github_api_v3/client/oauth.rb', line 34

def authorization(id)
  get "/authorizations/#{id}"
end

#authorizationsArray

List your authorizations.

Requires basic authentication.

Examples:

client = GitHub.client(:login => 'username', :password => 'password')
client.authorizations

Returns:

  • (Array)

    List of authorizations.

See Also:



20
21
22
# File 'lib/github_api_v3/client/oauth.rb', line 20

def authorizations
  get "/authorizations"
end

#create_authorization(options = {}) ⇒ Hash

Create a new authorization.

Requires basic authentication.

Examples:

client = GitHub.client(:login => 'username', :password => 'password')
client.create_authorization(
  :note => 'New authorization',
  :client_id => 'ab0487b031b18f9286a6',
  :client_secret => '9d667c2b7fae7a329f32b6df17926154'
)

Parameters:

  • options (Hash) (defaults to: {})

    Optional parameters.

Options Hash (options):

  • :scopes (Array)

    A list of scopes to create the authorization using.

  • :note (String)

    Note to remind what the OAuth token is for.

  • :note_url (String)

    URL to remind you what the OAuth token is for.

  • :client_id (String)

    The 20 character OAuth app client key for which to create the token.

  • :client_secret (String)

    The 40 character OAuth app client secret for which to create the token.

Returns:

  • (Hash)

    The new OAuth token information.

See Also:



57
58
59
# File 'lib/github_api_v3/client/oauth.rb', line 57

def create_authorization(options={})
  post "/authorizations", body: options
end

#delete_authorization(id) ⇒ Boolean

Delete an authorization

Requires basic authentication.

Examples:

client = GitHub.client(:login => 'username', :password => 'password')
client.delete_authorization(1324)

Parameters:

  • id (Integer)

    The ID of the authorization to delete.

Returns:

  • (Boolean)

    True if successful, false if not.

See Also:



91
92
93
# File 'lib/github_api_v3/client/oauth.rb', line 91

def delete_authorization(id)
  boolean_request :delete, "/authorizations/#{id}"
end

#update_authorization(id, options = {}) ⇒ Hash

Update an existing authorization.

Requires basic authentication.

Examples:

client = GitHub.client(:login => 'username', :password => 'password')
client.update_authorization(1324, :note => 'Updated authorization')

Parameters:

  • id (Integer)

    The ID of the authorization to update.

  • options (Hash) (defaults to: {})

    Optional parameters.

Options Hash (options):

  • :scopes (Array)

    Replaces the authorization scopes with these.

  • :add_scopes (Array)

    A list of scopes to add to this authorization.

  • :remove_scopes (Array)

    A list of scopes to remove from this authorization.

  • :note (String)

    Note to remind what the OAuth token is for.

  • :note_url (String)

    URL to remind you what the OAuth token is for.

Returns:

  • (Hash)

    The updated OAuth token information.

See Also:



77
78
79
# File 'lib/github_api_v3/client/oauth.rb', line 77

def update_authorization(id, options={})
  patch "/authorizations/#{id}", body: options
end