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 authorization(authorization_id, params={})


@github.oauth.authorization 'authorization-id'
@github = Github.new :basic_auth => 'login:password'
= Examples

Get a single authorization
def authorization(authorization_id, params={})
  _validate_presence_of(authorization_id)
  _check_if_authenticated
  _normalize_params_keys params
  get "/authorizations/#{authorization_id}", params
end

def authorizations(params={})


@github.oauth.authorizations { |auth| ... }
@github.oauth.authorizations
@github = Github.new :basic_auth => 'login:password'
= Examples

List authorizations
def authorizations(params={})
  _check_if_authenticated
  _normalize_params_keys(params)
  response = get("/authorizations", params)
  return response unless block_given?
  response.each { |el| yield el }
end

def create_authorization(params={})


"scopes" => ["public_repo"]
@github.oauth.create_authorization
@github = Github.new :basic_auth => 'login:password'
= Examples
* :scopes - Optional array - A list of scopes that this authorization is in.
= Inputs

Create a new authorization
def create_authorization(params={})
  _check_if_authenticated
  _normalize_params_keys(params)
  _filter_params_keys(VALID_AUTH_PARAM_NAMES, params)
  post("/authorizations", params)
end

def delete_authorization(authorization_id, params={})


@github.oauth.delete_authorization 'authorization-id'
= Examples

Delete an authorization
def delete_authorization(authorization_id, params={})
  _check_if_authenticated
  _validate_presence_of(authorization_id)
  _normalize_params_keys(params)
  _filter_params_keys(VALID_AUTH_PARAM_NAMES, params)
  delete("/authorizations/#{authorization_id}", params)
end

def initialize(options = {})

Creates new OAuth Authorizations API
def initialize(options = {})
  super(options)
end

def update_authorization(authorization_id, params={})


"add_scopes" => ["repo"],
@github.oauth.update_authorization
@github = Github.new :basic_auth => 'login:password'
= Examples

* :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_authorization(authorization_id, params={})
  _check_if_authenticated
  _validate_presence_of(authorization_id)
  _normalize_params_keys(params)
  _filter_params_keys(VALID_AUTH_PARAM_NAMES, params)
  patch("/authorizations/#{authorization_id}", params)
end