Class: Flickr::Auth
Instance Attribute Summary collapse
-
#token ⇒ Object
Returns the value of attribute token.
-
#token_cache ⇒ Object
Returns the value of attribute token_cache.
Attributes inherited from APIBase
Instance Method Summary collapse
- #cache_token ⇒ Object
- #clear_cache ⇒ Object
- #frob ⇒ Object
- #frob=(frob) ⇒ Object
- #getFrob ⇒ Object
- #getFullToken(mini_token) ⇒ Object
- #getToken(frob = nil) ⇒ Object
-
#initialize(flickr, token_cache = nil) ⇒ Auth
constructor
A new instance of Auth.
- #login_link(perms = 'delete') ⇒ Object
Constructor Details
#initialize(flickr, token_cache = nil) ⇒ Auth
Returns a new instance of Auth.
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/flickr/auth.rb', line 14 def initialize(flickr, token_cache=nil) super(flickr) @frob = nil @token = nil @token_cache = case token_cache when String Flickr::FileTokenCache.new token_cache else token_cache end @token = @token_cache.load_token if @token_cache end |
Instance Attribute Details
#token ⇒ Object
Returns the value of attribute token.
7 8 9 |
# File 'lib/flickr/auth.rb', line 7 def token @token end |
#token_cache ⇒ Object
Returns the value of attribute token_cache.
7 8 9 |
# File 'lib/flickr/auth.rb', line 7 def token_cache @token_cache end |
Instance Method Details
#cache_token ⇒ Object
45 46 47 |
# File 'lib/flickr/auth.rb', line 45 def cache_token @token_cache.cache_token(@token) if @token_cache end |
#clear_cache ⇒ Object
9 10 11 12 |
# File 'lib/flickr/auth.rb', line 9 def clear_cache @token = nil @frob = nil end |
#frob ⇒ Object
36 |
# File 'lib/flickr/auth.rb', line 36 def frob() return @frob || getFrob end |
#frob=(frob) ⇒ Object
35 |
# File 'lib/flickr/auth.rb', line 35 def frob=(frob) @frob = frob end |
#getFrob ⇒ Object
55 56 57 58 59 |
# File 'lib/flickr/auth.rb', line 55 def getFrob doc = @flickr.call_unauth_method('flickr.auth.getFrob') @frob = doc.elements['/frob'].text return @frob end |
#getFullToken(mini_token) ⇒ Object
49 50 51 52 53 |
# File 'lib/flickr/auth.rb', line 49 def getFullToken(mini_token) res = flickr.call_unauth_method('flickr.auth.getFullToken', 'mini_token' => mini_token) @token = Flickr::Token.from_xml(res) end |
#getToken(frob = nil) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/flickr/auth.rb', line 38 def getToken(frob=nil) frob ||= @frob res=@flickr.call_unauth_method('flickr.auth.getToken', 'frob'=>frob) @token = Flickr::Token.from_xml(res) end |
#login_link(perms = 'delete') ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/flickr/auth.rb', line 27 def login_link(perms='delete') args={ 'api_key' => @flickr.api_key, 'perms' => perms} args['frob'] = self.frob args['api_sig'] = @flickr.sign(args) return "http://flickr.com/services/auth/?"+ args.to_a.map{|arr| arr.join('=')}.join('&') end |