Class: OmniAuth::Strategies::Vimeo
- Defined in:
- lib/omniauth/strategies/oauth/vimeo.rb
Overview
Authenticate to Vimeo via OAuth and retrieve basic user information.
Usage:
use OmniAuth::Strategies::Vimeo, '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) ⇒ Vimeo
constructor
A new instance of Vimeo.
- #user_hash ⇒ Object
- #user_info ⇒ Object
Methods inherited from OAuth
#callback_phase, #consumer, #request_phase, #unique_id
Constructor Details
#initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block) ⇒ Vimeo
Returns a new instance of Vimeo.
14 15 16 17 18 19 20 21 22 |
# File 'lib/omniauth/strategies/oauth/vimeo.rb', line 14 def initialize(app, consumer_key=nil, consumer_secret=nil, ={}, &block) = { :access_token_path => '/oauth/access_token', :authorize_path => '/oauth/authorize', :request_token_path => '/oauth/request_token', :site => 'http://vimeo.com', } super(app, :vimeo, consumer_key, consumer_secret, , , &block) end |
Instance Method Details
#auth_hash ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/omniauth/strategies/oauth/vimeo.rb', line 24 def auth_hash user = user_hash['person'] OmniAuth::Utils.deep_merge( super, { 'uid' => user['id'], 'user_info' => user_info, 'extra' => { 'user_hash' => user, }, } ) end |
#user_hash ⇒ Object
52 53 54 55 |
# File 'lib/omniauth/strategies/oauth/vimeo.rb', line 52 def user_hash url = 'http://vimeo.com/api/rest/v2?method=vimeo.people.getInfo&format=json' @user_hash ||= MultiJson.decode(@access_token.get(url).body) end |
#user_info ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/omniauth/strategies/oauth/vimeo.rb', line 37 def user_info user = user_hash['person'] { 'nickname' => user['username'], 'name' => user['display_name'], 'location' => user['location'], 'description' => user['bio'], 'image' => user['portraits']['portrait'].select{|h| h['height'] == '300'}.first['_content'], 'urls' => { 'website' => user['url'], 'vimeo' => user['profileurl'], }, } end |