Class: Atig::OAuth
- Inherits:
-
Object
- Object
- Atig::OAuth
- Defined in:
- lib/atig/oauth.rb
Constant Summary collapse
- CONSUMER_KEY =
'TO9wbD379qmFSJp6pFs5w'
- CONSUMER_SECRET =
'Gap8ishP3J3JrjH4JEspcii4poiZgMowHRazWGM1cYg'
- @@profiles =
{}
Instance Attribute Summary collapse
-
#access ⇒ Object
readonly
Returns the value of attribute access.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(context, nick) ⇒ OAuth
constructor
A new instance of OAuth.
- #url ⇒ Object
- #verified? ⇒ Boolean
- #verify(code) ⇒ Object
Constructor Details
#initialize(context, nick) ⇒ OAuth
Returns a new instance of OAuth.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/atig/oauth.rb', line 23 def initialize(context, nick) uri = URI(context.opts.api_base) site = "http://#{uri.host}" @nick = nick @oauth = ::OAuth::Consumer.new(CONSUMER_KEY, CONSUMER_SECRET, { :site => site, :proxy => ENV["HTTP_PROXY"] || ENV["http_proxy"] }) if @@profiles.key? @nick token,secret = @@profiles[@nick] @access = ::OAuth::AccessToken.new(@oauth, token, secret) end end |
Instance Attribute Details
#access ⇒ Object (readonly)
Returns the value of attribute access.
22 23 24 |
# File 'lib/atig/oauth.rb', line 22 def access @access end |
Class Method Details
.dump ⇒ Object
13 14 15 |
# File 'lib/atig/oauth.rb', line 13 def dump @@profiles end |
.load(profiles) ⇒ Object
17 18 19 |
# File 'lib/atig/oauth.rb', line 17 def load(profiles) @@profiles = profiles end |
Instance Method Details
#url ⇒ Object
43 44 45 46 |
# File 'lib/atig/oauth.rb', line 43 def url @request = @oauth.get_request_token @request. end |
#verified? ⇒ Boolean
39 40 41 |
# File 'lib/atig/oauth.rb', line 39 def verified? @access != nil end |
#verify(code) ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/atig/oauth.rb', line 48 def verify(code) @access = @request.get_access_token(:oauth_verifier => code) if @access then @@profiles[@nick] = [ @access.token , @access.secret ] end rescue false end |