### Home Classes Methods

### In Files

- lib/github_api/authorization.rb

### Methods

- #auth_code
- #authenticated?
- #authentication
- #authorize_url
- #basic_authed?
- #client
- #get_token

### Class/Module Index

Quicksearch

- Github
- Github::API
- Github::Activity
- Github::Activity::Events
- Github::Activity::Notifications
- Github::Activity::Starring
- Github::Activity::Watching
- Github::ApiFactory
- Github::Arguments
- Github::Authorization
- Github::Authorizations
- Github::AutoloadHelper
- Github::Client
- Github::Configuration
- Github::Connection
- Github::Constants
- Github::CoreExt
- Github::CoreExt::OrderedHash
- Github::Descendants
- Github::Emojis
- Github::Error
- Github::Error::BadRequest
- Github::Error::ClientError
- Github::Error::Forbidden
- Github::Error::GithubError
- Github::Error::InternalServerError
- Github::Error::InvalidOptions
- Github::Error::NotAcceptable
- Github::Error::NotFound
- Github::Error::RequiredParams
- Github::Error::ServiceError
- Github::Error::ServiceUnavailable
- Github::Error::Unauthorized
- Github::Error::UnknownValue
- Github::Error::UnprocessableEntity
- Github::Error::Validations
- Github::Gists
- Github::Gists::Comments
- Github::GitData
- Github::GitData::Blobs
- Github::GitData::Commits
- Github::GitData::References
- Github::GitData::Tags
- Github::GitData::Trees
- Github::Gitignore
- Github::Issues
- Github::Issues::Assignees
- Github::Issues::Comments
- Github::Issues::Events
- Github::Issues::Labels
- Github::Issues::Milestones
- Github::Jsonable
- Github::Markdown
- Github::Meta
- Github::MimeType
- Github::Normalizer
- Github::Orgs
- Github::Orgs::Members
- Github::Orgs::Teams
- Github::PageIterator
- Github::PageLinks
- Github::PagedRequest
- Github::Pagination
- Github::ParameterFilter
- Github::ParamsHash
- Github::PullRequests
- Github::PullRequests::Comments
- Github::RateLimit
- Github::Repos
- Github::Repos::Collaborators
- Github::Repos::Comments
- Github::Repos::Commits
- Github::Repos::Contents
- Github::Repos::Downloads
- Github::Repos::Forks
- Github::Repos::Hooks
- Github::Repos::Keys
- Github::Repos::Merging
- Github::Repos::PubSubHubbub
- Github::Repos::Statistics
- Github::Repos::Statuses
- Github::Request
- Github::Request::BasicAuth
- Github::Request::Jsonize
- Github::Request::OAuth2
- Github::Resource
- Github::Response
- Github::Response::Header
- Github::Response::Jsonize
- Github::Response::Mashify
- Github::Response::RaiseError
- Github::Response::Xmlize
- Github::ResponseWrapper
- Github::S3Uploader
- Github::Say
- Github::Scopes
- Github::Search
- Github::Users
- Github::Users::Emails
- Github::Users::Followers
- Github::Users::Keys
- Github::Utils
- Github::Utils::Url
- Github::VERSION
- Github::Validations
- Github::Validations::Format
- Github::Validations::Presence
- Github::Validations::Required
- Github::Validations::Token
- Hash

No matching classes.

# Github::Authorization

### Attributes

scopes[RW]

### Public Instance Methods

auth_code() click to toggle source

Strategy token

    # File lib/github_api/authorization.rb, line 20
    def auth_code
      _verify_client
      client.auth_code
    end

authenticated?() click to toggle source

Check whether authentication credentials are present

    # File lib/github_api/authorization.rb, line 48
    def authenticated?
      basic_authed? || oauth_token?
    end

authentication() click to toggle source

Select authentication parameters

    # File lib/github_api/authorization.rb, line 58
    def authentication
      if basic_auth?
        { :basic_auth => basic_auth }
      elsif login? && password?
        { :login => login, :password => password }
      else
        { }
      end
    end

authorize_url(params = {}) click to toggle source

Sends authorization request to GitHub.

# Parameters

- `:redirect_uri` - Optional string.

- `:scope` - Optional string. Comma separated list of scopes. Available scopes:

  - (no scope) - public read-only access (includes public user profile info, public repo info, and gists).

  - `user` - DB read/write access to profile info only.

  - `public_repo` - DB read/write access, and Git read access to public repos.

  - `repo` - DB read/write access, and Git read access to public and private repos.

  - `gist` - write access to gists.

    # File lib/github_api/authorization.rb, line 36
    def authorize_url(params = {})
      _verify_client
      client.auth_code.authorize_url(params)
    end

basic_authed?() click to toggle source

Check whether basic authentication credentials are present

    # File lib/github_api/authorization.rb, line 53
    def basic_authed?
      basic_auth? || (login? && password?)
    end

client() click to toggle source

Setup OAuth2 instance

    # File lib/github_api/authorization.rb, line 8
    def client
      @client ||= ::OAuth2::Client.new(client_id, client_secret,
        {
          :site          => current_options.fetch(:site) { Github.site },
          :authorize_url => 'login/oauth/authorize',
          :token_url     => 'login/oauth/access_token',
          :ssl           => { :verify => false }
        }
      )
    end

get_token(authorization_code, params = {}) click to toggle source

Makes request to token endpoint and retrieves access token value

    # File lib/github_api/authorization.rb, line 42
    def get_token(authorization_code, params = {})
      _verify_client
      client.auth_code.get_token(authorization_code, params)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.