Class: OmniAuth::Strategies::SmugMug
- Defined in:
- lib/omniauth/strategies/oauth/smug_mug.rb
Overview
Authenticate to SmugMug via OAuth and retrieve basic user information.
Usage: use OmniAuth::Strategies::SmugMug, 'consumerkey', 'consumersecret'
Instance Attribute Summary
Attributes inherited from OAuth
#consumer_key, #consumer_options, #consumer_secret, #name
Instance Method Summary collapse
- #auth_hash ⇒ Object
-
#initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block) ⇒ SmugMug
constructor
A new instance of SmugMug.
-
#user_hash ⇒ Object
info as supplied by SmugMug.
-
#user_info ⇒ Object
user info according to schema.
Methods inherited from OAuth
#callback_phase, #consumer, #request_phase, #unique_id
Constructor Details
#initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block) ⇒ SmugMug
Returns a new instance of SmugMug.
11 12 13 14 15 16 17 18 19 |
# File 'lib/omniauth/strategies/oauth/smug_mug.rb', line 11 def initialize(app, consumer_key=nil, consumer_secret=nil, ={}, &block) = { :access_token_path => '/services/oauth/getAccessToken.mg', :authorize_path => '/services/oauth/authorize.mg', :site => 'http://api.smugmug.com', :request_token_path => '/services/oauth/getRequestToken.mg', } super(app, :smugmug, consumer_key, consumer_secret, , , &block) end |
Instance Method Details
#auth_hash ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/omniauth/strategies/oauth/smug_mug.rb', line 21 def auth_hash OmniAuth::Utils.deep_merge( super, { 'uid' => user_hash['id'], 'user_info' => user_info, 'extra' => { 'user_hash' => user_hash, }, } ) end |
#user_hash ⇒ Object
info as supplied by SmugMug
42 43 44 |
# File 'lib/omniauth/strategies/oauth/smug_mug.rb', line 42 def user_hash @user_hash ||= MultiJson.decode(@access_token.get('/services/api/json/1.2.2/?method=smugmug.auth.checkAccessToken').body)['Auth']['User'] end |
#user_info ⇒ Object
user info according to schema
34 35 36 37 38 39 |
# File 'lib/omniauth/strategies/oauth/smug_mug.rb', line 34 def user_info { 'nickname' => user_hash['NickName'], 'name' => user_hash['NickName'] } end |