Create a new authorization
:scopes
- Optional array - A list of scopes that this
authorization is in.
:note
- Optional string - A note to remind you what the OAuth
token is for.
:note_url
- Optional string - A URL to remind you what the
OAuth token is for.
github = Github.new :basic_auth => 'login:password' github.oauth.create "scopes" => ["public_repo"]
# File lib/github_api/authorizations.rb, line 58 def create(*args) _check_if_authenticated arguments(args) do sift VALID_AUTH_PARAM_NAMES end post_request("/authorizations", arguments.params) end
Delete an authorization
github.oauth.delete 'authorization-id'
# File lib/github_api/authorizations.rb, line 95 def delete(*args) _check_if_authenticated arguments(args, :required => [:authorization_id]) delete_request("/authorizations/#{authorization_id}", arguments.params) end
Get a single authorization
github = Github.new :basic_auth => 'login:password' github.oauth.get 'authorization-id'
# File lib/github_api/authorizations.rb, line 38 def get(*args) _check_if_authenticated arguments(args, :required => [:authorization_id]) get_request("/authorizations/#{authorization_id}", arguments.params) end
List authorizations
github = Github.new :basic_auth => 'login:password' github.oauth.list github.oauth.list { |auth| ... }
# File lib/github_api/authorizations.rb, line 22 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
Update an existing authorization
:scopes
- Optional array - A list of scopes that this
authorization is in.
:add_scopes
- Optional array - A list of scopes to add to this
authorization.
:remove_scopes
- Optional array - A list of scopes to remove
from this authorization.
:note
- Optional string - A note to remind you what the OAuth
token is for.
:note_url
- Optional string - A URL to remind you what the
OAuth token is for.
github = Github.new :basic_auth => 'login:password' github.oauth.update "authorization-id", "add_scopes" => ["repo"],
# File lib/github_api/authorizations.rb, line 80 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
# File lib/github_api/authorizations.rb, line 105 def _check_if_authenticated raise ArgumentError, 'You can only access authentication tokens through Basic Authentication' unless authenticated? end