Class: OmniAuth::Strategies::Flickr

Inherits:
OAuth
  • Object
show all
Defined in:
lib/omniauth/strategies/flickr.rb

Overview

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

Instance Method Summary collapse

Instance Method Details

#image_infoObject



68
69
70
71
72
73
74
# File 'lib/omniauth/strategies/flickr.rb', line 68

def image_info
  if ["iconfarm"] && ["iconfarm"] > 0
    "http://farm#{["iconfarm"]}.static.flickr.com/#{["iconserver"]}/buddyicons/#{uid}.jpg"
  else
    "https://www.flickr.com/images/buddyicon.gif"
  end
end

#raw_infoObject

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



54
55
56
57
58
59
60
# 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_phaseObject



76
77
78
79
80
# 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_infoObject

Provide the “Person” portion of the raw_info



64
65
66
# File 'lib/omniauth/strategies/flickr.rb', line 64

def 
  @user_info ||= raw_info.nil? ? {} : raw_info["person"]
end