class Github::Authorizations
def _check_if_authenticated
def _check_if_authenticated raise ArgumentError, 'You can only access authentication tokens through Basic Authentication' unless authenticated? end
def create(*args)
"scopes" => ["public_repo"]
github.oauth.create
github = Github.new :basic_auth => 'login:password'
= Examples
* :note_url - Optional string - A URL to remind you what the OAuth token is for.
* :note - Optional string - A note to remind you what the OAuth token is for.
* :scopes - Optional array - A list of scopes that this authorization is in.
= Inputs
Create a new authorization
def create(*args) _check_if_authenticated arguments(args) do sift VALID_AUTH_PARAM_NAMES end post_request("/authorizations", arguments.params) end
def delete(*args)
github.oauth.delete 'authorization-id'
= Examples
Delete an authorization
def delete(*args) _check_if_authenticated arguments(args, :required => [:authorization_id]) delete_request("/authorizations/#{authorization_id}", arguments.params) end
def get(*args)
github.oauth.get 'authorization-id'
github = Github.new :basic_auth => 'login:password'
= Examples
Get a single authorization
def get(*args) _check_if_authenticated arguments(args, :required => [:authorization_id]) get_request("/authorizations/#{authorization_id}", arguments.params) end
def list(*args)
github.oauth.list { |auth| ... }
github.oauth.list
github = Github.new :basic_auth => 'login:password'
= Examples
List authorizations
def list(*args) _check_if_authenticated arguments(args) response = get_request("/authorizations", arguments.params) return response unless block_given? response.each { |el| yield el } end
def update(*args)
github.oauth.update "authorization-id", "add_scopes" => ["repo"],
github = Github.new :basic_auth => 'login:password'
= Examples
* :note_url - Optional string - A URL to remind you what the OAuth token is for.
* :note - Optional string - A note to remind you what the OAuth token is for.
* :remove_scopes - Optional array - A list of scopes to remove from this authorization.
* :add_scopes - Optional array - A list of scopes to add to this authorization.
* :scopes - Optional array - A list of scopes that this authorization is in.
= Inputs
Update an existing authorization
def update(*args) _check_if_authenticated arguments(args, :required => [:authorization_id]) do sift VALID_AUTH_PARAM_NAMES end patch_request("/authorizations/#{authorization_id}", arguments.params) end