Class: Stormpath::Rails::GithubAuthCodeExchange

Inherits:
Object
  • Object
show all
Defined in:
lib/stormpath/rails/github_auth_code_exchange.rb

Constant Summary collapse

GITHUB_EXCHANGE_URL =
URI('https://github.com/login/oauth/access_token')

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root_url, code) ⇒ GithubAuthCodeExchange

Returns a new instance of GithubAuthCodeExchange.



8
9
10
11
12
# File 'lib/stormpath/rails/github_auth_code_exchange.rb', line 8

def initialize(root_url, code)
  raise(NoGithubAuthorizationError) if code.nil?
  @root_url = root_url
  @code = code
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



6
7
8
# File 'lib/stormpath/rails/github_auth_code_exchange.rb', line 6

def code
  @code
end

#root_urlObject (readonly)

Returns the value of attribute root_url.



6
7
8
# File 'lib/stormpath/rails/github_auth_code_exchange.rb', line 6

def root_url
  @root_url
end

Instance Method Details

#access_tokenObject



14
15
16
# File 'lib/stormpath/rails/github_auth_code_exchange.rb', line 14

def access_token
  @access_token ||= fetch_access_token(exchange_auth_code.body)
end