Class: Flickr::Auth
Defined Under Namespace
Classes: Token
Constant Summary
Constants inherited from Base
Base::AUTH_ENDPOINT, Base::REST_ENDPOINT, Base::UPLOAD_ENDPOINT
Instance Attribute Summary
Attributes inherited from Base
#api_key, #api_secret, #token_cache
Instance Method Summary collapse
-
#cache_token(filename = @flickr.token_cache) ⇒ Object
saves the current token to the cache file if token exists.
-
#frob ⇒ Object
get or return a frob to use for authentication.
-
#frob=(frob) ⇒ Object
set the frob.
-
#initialize(flickr) ⇒ Auth
constructor
A new instance of Auth.
-
#token(pass_through = true) ⇒ Object
gets the token object for the current frob.
-
#url(perms = :read) ⇒ Object
generates the authorization url to allow access to a flickr account.
Methods inherited from Base
#auth, #contacts, #people, #photos, #photosets, #send_request, #sign_request, #test, #uploader, #urls
Constructor Details
#initialize(flickr) ⇒ Auth
Returns a new instance of Auth.
2 3 4 |
# File 'lib/flickr/auth.rb', line 2 def initialize(flickr) @flickr = flickr end |
Instance Method Details
#cache_token(filename = @flickr.token_cache) ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/flickr/auth.rb', line 47 def cache_token(filename = @flickr.token_cache) if filename and self.token cache_file = File.open(filename, 'w+') cache_file.puts self.token.to_yaml cache_file.close true else false end end |
#frob ⇒ Object
get or return a frob to use for authentication
7 8 9 |
# File 'lib/flickr/auth.rb', line 7 def frob @frob ||= get_frob end |
#frob=(frob) ⇒ Object
set the frob
12 13 14 |
# File 'lib/flickr/auth.rb', line 12 def frob= frob @frob=frob end |
#token(pass_through = true) ⇒ Object
gets the token object for the current frob
Params
-
pass_through (Optional)
Boolean value that determines if a call will be made to flickr to find a taken for the current frob if empty
37 38 39 |
# File 'lib/flickr/auth.rb', line 37 def token(pass_through = true) @token ||= get_token(pass_through) rescue nil end |
#url(perms = :read) ⇒ Object
generates the authorization url to allow access to a flickr account.
Params
-
perms (Optional)
sets the permision level to grant on the flickr account. :read - permission to read private information (DEFAULT) :write - permission to add, edit and delete photo metadata (includes 'read') :delete - permission to delete photos (includes 'write' and 'read')
25 26 27 28 29 |
# File 'lib/flickr/auth.rb', line 25 def url(perms = :read) = {:api_key => @flickr.api_key, :perms => perms, :frob => self.frob} @flickr.sign_request() Flickr::Base::AUTH_ENDPOINT + "?" + .collect{|k,v| "#{k}=#{v}"}.join('&') end |