module Octokit::Client::OauthApplications

Methods for the OauthApplications API

@see developer.github.com/v3/apps/oauth_applications

Public Instance Methods

check_application_authorization(access_token, options = {})
Alias for: check_token
check_token(access_token, options = {}) click to toggle source

Check if a token is valid.

Applications can check if a token is valid without rate limits.

@param access_token [String] 40 character GitHub OAuth access token

@return [Sawyer::Resource] A single authorization for the authenticated user @see developer.github.com/v3/apps/oauth_applications/#check-a-token

@example

client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
client.check_token('deadbeef1234567890deadbeef987654321')
# File lib/octokit/client/oauth_applications.rb, line 23
def check_token(access_token, options = {})
  options = ensure_api_media_type(:applications_api, options.dup)
  options[:access_token] = access_token

  key    = options.delete(:client_id)     || client_id
  secret = options.delete(:client_secret) || client_secret

  as_app(key, secret) do |app_client|
    app_client.post "applications/#{client_id}/token", options
  end
end
delete_app_authorization(access_token, options = {}) click to toggle source

Delete an app authorization

OAuth application owners can revoke a grant for their OAuth application and a specific user.

@param accces_token [String] 40 character GitHub OAuth access token

@return [Boolean] Result @see developer.github.com/v3/apps/oauth_applications/#delete-an-app-token

@example

client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
client.delete_app_authorization('deadbeef1234567890deadbeef987654321')
# File lib/octokit/client/oauth_applications.rb, line 104
def delete_app_authorization(access_token, options = {})
  options = ensure_api_media_type(:applications_api, options.dup)
  options[:access_token] = access_token

  key    = options.delete(:client_id)     || client_id
  secret = options.delete(:client_secret) || client_secret

  begin
    as_app(key, secret) do |app_client|
      app_client.delete "applications/#{client_id}/grant", options
      app_client.last_response.status == 204
    end
  rescue Octokit::NotFound
    false
  end
end
delete_app_token(access_token, options = {}) click to toggle source

Delete an app token

Applications can revoke (delete) a token

@param token [String] 40 character GitHub OAuth access token

@return [Boolean] Result @see developer.github.com/v3/apps/oauth_applications/#delete-an-app-token

@example

client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
client.delete_token('deadbeef1234567890deadbeef987654321')
# File lib/octokit/client/oauth_applications.rb, line 73
def delete_app_token(access_token, options = {})
  options = ensure_api_media_type(:applications_api, options.dup)
  options[:access_token] = access_token

  key    = options.delete(:client_id)     || client_id
  secret = options.delete(:client_secret) || client_secret

  begin
    as_app(key, secret) do |app_client|
      app_client.delete "applications/#{client_id}/token", options
      app_client.last_response.status == 204
    end
  rescue Octokit::NotFound
    false
  end
end
delete_application_authorization(access_token, options = {})
Alias for: delete_app_token
reset_application_authorization(access_token, options = {})
Alias for: reset_token
reset_token(access_token, options = {}) click to toggle source

Reset a token

Applications can reset a token without requiring a user to re-authorize.

@param access_token [String] 40 character GitHub OAuth access token

@return [Sawyer::Resource] A single authorization for the authenticated user @see developer.github.com/v3/apps/oauth_applications/#reset-a-token

@example

client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
client.reset_token('deadbeef1234567890deadbeef987654321')
# File lib/octokit/client/oauth_applications.rb, line 48
def reset_token(access_token, options = {})
  options = ensure_api_media_type(:applications_api, options.dup)
  options[:access_token] = access_token

  key    = options.delete(:client_id)     || client_id
  secret = options.delete(:client_secret) || client_secret

  as_app(key, secret) do |app_client|
    app_client.patch "applications/#{client_id}/token", options
  end
end
revoke_application_authorization(access_token, options = {})
Alias for: delete_app_token