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.
-
#oauth ⇒ Object
readonly
Returns the value of attribute oauth.
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.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/atig/oauth.rb', line 25 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 |
#oauth ⇒ Object (readonly)
Returns the value of attribute oauth.
23 24 25 |
# File 'lib/atig/oauth.rb', line 23 def oauth @oauth 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
45 46 47 48 |
# File 'lib/atig/oauth.rb', line 45 def url @request = @oauth.get_request_token @request. end |
#verified? ⇒ Boolean
41 42 43 |
# File 'lib/atig/oauth.rb', line 41 def verified? @access != nil end |
#verify(code) ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/atig/oauth.rb', line 50 def verify(code) @access = @request.get_access_token(:oauth_verifier => code) if @access then @@profiles[@nick] = [ @access.token , @access.secret ] end rescue false end |