lib/flickr/auth.rb in fotonauts-flickr_fu-0.3.4 vs lib/flickr/auth.rb in fotonauts-flickr_fu-0.3.6
- old
+ new
@@ -5,47 +5,51 @@
# get or return a frob to use for authentication
def frob
@frob ||= get_frob
end
-
+
# set the frob
def frob= frob
@frob=frob
end
# 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')
- #
- def url(perms = :read)
- options = {:api_key => @flickr.api_key, :perms => perms, :frob => self.frob}
+ # * options (Optional)
+ # additional parameters to pass to flickr. The most common use-case for
+ # this is to pass the (undocumented) :extra parameter that is returned
+ # back from flickr during the callback.
+ #
+ def url(perms = :read, options = {})
+ options.merge!(:api_key => @flickr.api_key, :perms => perms, :frob => self.frob)
@flickr.sign_request(options)
- Flickr::Base::AUTH_ENDPOINT + "?" + options.collect{|k,v| "#{k}=#{v}"}.join('&')
+ Flickr::Base::AUTH_ENDPOINT + "?" + options.collect{|k,v| "#{k}=#{CGI.escape(v.to_s)}"}.join('&')
end
# 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
- #
+ #
def token(pass_through = true)
@token ||= get_token(pass_through) rescue nil
end
# saves the current token to the cache file if token exists
- #
+ #
# Param
# * filename (Optional)
# filename of the cache file. defaults to the file passed into Flickr.new
- #
+ #
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
@@ -71,6 +75,6 @@
rsp = @flickr.send_request('flickr.auth.getToken', {:frob => self.frob})
Token.new(:token => rsp.auth.token.to_s, :permisions => rsp.auth.perms.to_s, :user_id => rsp.auth.user[:nsid], :username => rsp.auth.user[:username], :user_real_name => rsp.auth.user[:fullname])
end
end
-end
\ No newline at end of file
+end