Class: Warden::GitHub::OAuth

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

Constant Summary collapse

BadVerificationCode =
Class.new(StandardError)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ OAuth

Returns a new instance of OAuth.



16
17
18
19
20
21
22
23
# File 'lib/warden/github/oauth.rb', line 16

def initialize(attrs={})
  @code = attrs[:code]
  @state = attrs[:state]
  @scope = attrs[:scope]
  @client_id = attrs.fetch(:client_id)
  @client_secret = attrs.fetch(:client_secret)
  @redirect_uri = attrs.fetch(:redirect_uri)
end

Instance Attribute Details

#client_idObject (readonly)

Returns the value of attribute client_id.



9
10
11
# File 'lib/warden/github/oauth.rb', line 9

def client_id
  @client_id
end

#client_secretObject (readonly)

Returns the value of attribute client_secret.



9
10
11
# File 'lib/warden/github/oauth.rb', line 9

def client_secret
  @client_secret
end

#codeObject (readonly)

Returns the value of attribute code.



9
10
11
# File 'lib/warden/github/oauth.rb', line 9

def code
  @code
end

#redirect_uriObject (readonly)

Returns the value of attribute redirect_uri.



9
10
11
# File 'lib/warden/github/oauth.rb', line 9

def redirect_uri
  @redirect_uri
end

#scopeObject (readonly)

Returns the value of attribute scope.



9
10
11
# File 'lib/warden/github/oauth.rb', line 9

def scope
  @scope
end

#stateObject (readonly)

Returns the value of attribute state.



9
10
11
# File 'lib/warden/github/oauth.rb', line 9

def state
  @state
end

Instance Method Details

#access_tokenObject



34
35
36
# File 'lib/warden/github/oauth.rb', line 34

def access_token
  @access_token ||= load_access_token
end

#authorize_uriObject



25
26
27
28
29
30
31
32
# File 'lib/warden/github/oauth.rb', line 25

def authorize_uri
  @authorize_uri ||= build_uri(
    '/login/oauth/authorize',
    :client_id => client_id,
    :redirect_uri => redirect_uri,
    :scope => scope,
    :state => state)
end