Module: Octokit::Client::Authorizations
- Included in:
- Octokit::Client
- Defined in:
- lib/octokit/client/authorizations.rb
Overview
Methods for the Authorizations API
Instance Method Summary collapse
-
#authorization(number, options = {}) ⇒ Sawyer::Resource
Get a single authorization for the authenticated user.
-
#authorizations(options = {}) ⇒ Array<Sawyer::Resource>
List the authenticated user’s authorizations.
-
#create_authorization(options = {}) ⇒ Sawyer::Resource
Create an authorization for the authenticated user.
-
#delete_authorization(number, options = {}) ⇒ Boolean
Delete an authorization for the authenticated user.
-
#scopes(token = @access_token) ⇒ Array<String>
Check scopes for a token.
-
#update_authorization(number, options = {}) ⇒ Sawyer::Resource
Update an authorization for the authenticated user.
Instance Method Details
#authorization(number, options = {}) ⇒ Sawyer::Resource
Get a single authorization for the authenticated user.
You can only access your own tokens, and only through Basic Authentication.
35 36 37 |
# File 'lib/octokit/client/authorizations.rb', line 35 def (number, = {}) get "authorizations/#{number}", end |
#authorizations(options = {}) ⇒ Array<Sawyer::Resource>
List the authenticated user’s authorizations
API for users to manage their own tokens. You can only access your own tokens, and only through Basic Authentication.
20 21 22 |
# File 'lib/octokit/client/authorizations.rb', line 20 def ( = {}) paginate 'authorizations', end |
#create_authorization(options = {}) ⇒ Sawyer::Resource
Create an authorization for the authenticated user.
You can create your own tokens, and only through Basic Authentication.
55 56 57 58 59 |
# File 'lib/octokit/client/authorizations.rb', line 55 def ( = {}) # Techincally we can omit scopes as GitHub has a default, however the # API will reject us if we send a POST request with an empty body. post 'authorizations', end |
#delete_authorization(number, options = {}) ⇒ Boolean
Delete an authorization for the authenticated user.
You can delete your own tokens, and only through Basic Authentication.
95 96 97 |
# File 'lib/octokit/client/authorizations.rb', line 95 def (number, = {}) boolean_from_response :delete, "authorizations/#{number}", end |
#scopes(token = @access_token) ⇒ Array<String>
Check scopes for a token
104 105 106 107 108 109 110 111 112 113 |
# File 'lib/octokit/client/authorizations.rb', line 104 def scopes(token = @access_token) raise ArgumentError.new("Access token required") if token.nil? agent.call(:get, "user", :headers => {"Authorization" => "token #{token}" }). headers['X-OAuth-Scopes']. to_s. split(','). map(&:strip). sort end |
#update_authorization(number, options = {}) ⇒ Sawyer::Resource
Update an authorization for the authenticated user.
You can update your own tokens, but only through Basic Authentication.
79 80 81 |
# File 'lib/octokit/client/authorizations.rb', line 79 def (number, = {}) patch "authorizations/#{number}", end |