class OmniAuth::Strategies::Flickr

An omniauth 1.0 strategy for Flickr authentication Based on www.flickr.com/services/api/auth.oauth.html

Public Instance Methods

image_info() click to toggle source
# File lib/omniauth/strategies/flickr.rb, line 68
def image_info
  if user_info["iconfarm"] && user_info["iconfarm"] > 0
    "http://farm#{user_info["iconfarm"]}.static.flickr.com/#{user_info["iconserver"]}/buddyicons/#{uid}.jpg"
  else
    "https://www.flickr.com/images/buddyicon.gif"
  end
end
raw_info() click to toggle source

Return info gathered from the flickr.people.getInfo API call

# File lib/omniauth/strategies/flickr.rb, line 54
def raw_info
  # This is a public API and does not need signing or authentication
  request = "/services/rest/?format=json&method=flickr.people.getInfo&nojsoncallback=1&user_id=#{uid}"
  @raw_info ||= MultiJson.decode(access_token.get(request).body)
rescue ::Errno::ETIMEDOUT
  raise ::Timeout::Error
end
request_phase() click to toggle source
Calls superclass method
# File lib/omniauth/strategies/flickr.rb, line 76
def request_phase
  options[:authorize_params] = {:perms => options[:scope]} if options[:scope]
  session['oauth'] ||= {} # https://github.com/timbreitkreutz/omniauth-flickr/issues/4
  super
end
user_info() click to toggle source

Provide the “Person” portion of the raw_info

# File lib/omniauth/strategies/flickr.rb, line 64
def user_info
  @user_info ||= raw_info.nil? ? {} : raw_info["person"]
end

Private Instance Methods

unwrap_hash_content(hash) click to toggle source

Flickr has a really annoying habit of wrapping values in { “_content” : “something” } This loops through an auth hash and converts these values into simple key / val

# File lib/omniauth/strategies/flickr.rb, line 85
def unwrap_hash_content(hash)
  hash.each do  |key, val|
    if val.respond_to? :has_key?
      hash[key] = val['_content'] if val.has_key?('_content')
    end
  end
end