Sha256: 8225b7f2a83b2bb712adb8f1fdf5dd06d7b7b54d81116bebb7d31d2fb1608b0b
Contents?: true
Size: 1.58 KB
Versions: 2
Compression:
Stored size: 1.58 KB
Contents
# encoding: utf-8 module Github module Authorization attr_accessor :scopes # Setup OAuth2 instance def client @client ||= ::OAuth2::Client.new(client_id, client_secret, :site => 'https://github.com', :authorize_url => 'login/oauth/authorize', :token_url => 'login/oauth/access_token' ) end # Strategy token def auth_code _verify_client @client.auth_code end # Sends authorization request to GitHub. # = Parameters # * <tt>:redirect_uri</tt> - Required string. # * <tt>:scope</tt> - 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). # * <tt>user</tt> - DB read/write access to profile info only. # * <tt>public_repo</tt> - DB read/write access, and Git read access to public repos. # * <tt>repo</tt> - DB read/write access, and Git read access to public and private repos. # * <tt>gist</tt> - write access to gists. # def authorize_url(params = {}) _verify_client @client.auth_code.authorize_url(params) end # Makes request to token endpoint and retrieves access token value def get_token(authorization_code, params = {}) _verify_client @client.auth_code.get_token(authorization_code, params) end private def _verify_client # :nodoc: raise ArgumentError, 'Need to provide client_id and client_secret' unless client_id? && client_secret? end end # Authorization end # Github
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
github_api-0.2.2 | lib/github_api/authorization.rb |
github_api-0.2.1 | lib/github_api/authorization.rb |