Class: FlickrTools::Auth
Overview
USAGE: flickr-tools Auth username
the username argument is just a shorthand to identify the same user in further calls to other flickr-tools commands, must not equal your flickr username.
Instance Method Summary collapse
Methods inherited from Command
Constructor Details
This class inherits a constructor from FlickrTools::Command
Instance Method Details
#authorize ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/flickr-tools/auth.rb', line 38 def @flickr = nil FileUtils.rm_f @token_cache puts "please visit the following url, then press <enter> once you have authorized:" # request permissions puts flickr.auth.url(:delete) STDIN.gets flickr.auth.cache_token end |
#check_token(required_perms = :write) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/flickr-tools/auth.rb', line 15 def check_token(required_perms = :write) res = flickr.auth.check_token allowed_perms = case required_perms when :read %w(read write delete) when :write %w(write delete) when :delete %w(delete) end perm = res.auth.perms.to_s if allowed_perms.include?(perm) true else puts "insufficient permissions: #{perm}, required was: #{required_perms}" false end rescue Exception puts "check_token failed: #{$!}\n#{$!.backtrace.join("\n")}" # authorize end |
#run ⇒ Object
11 12 13 |
# File 'lib/flickr-tools/auth.rb', line 11 def run end |