Class: Githubris::OAuth

Inherits:
Object
  • Object
show all
Defined in:
lib/githubris/oauth.rb

Constant Summary collapse

REQUEST_ACCESS_URL =
Addressable::URI.parse("https://github.com/login/oauth/authorize")

Instance Method Summary collapse

Constructor Details

#initialize(client_id, client_secret, api = Githubris::API.new) ⇒ OAuth

Returns a new instance of OAuth.



4
5
6
7
8
# File 'lib/githubris/oauth.rb', line 4

def initialize(client_id, client_secret, api=Githubris::API.new)
  @client_id = client_id
  @client_secret = client_secret
  @api = api
end

Instance Method Details

#access_token(code) ⇒ Object



14
15
16
# File 'lib/githubris/oauth.rb', line 14

def access_token(code)
  @api.post_oauth_access_token(access_token_params(code))
end

#request_access_url(query = {}) ⇒ Object



10
11
12
# File 'lib/githubris/oauth.rb', line 10

def request_access_url(query={})
  add_query_params_to(REQUEST_ACCESS_URL, query).to_s
end