Class: OmniAuth::Strategies::Netflix
- Defined in:
- lib/omniauth/strategies/oauth/netflix.rb
Overview
Authenticate to Netflix via OAuth and retrieve basic user information. Usage: use OmniAuth::Strategies::Netflix, '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) ⇒ Netflix
constructor
A new instance of Netflix.
- #request_phase ⇒ Object
- #user_hash ⇒ Object
- #user_info ⇒ Object
Methods inherited from OAuth
#callback_phase, #consumer, #unique_id
Constructor Details
#initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block) ⇒ Netflix
Returns a new instance of Netflix.
12 13 14 15 16 17 18 19 20 |
# File 'lib/omniauth/strategies/oauth/netflix.rb', line 12 def initialize(app, consumer_key=nil, consumer_secret=nil, ={}, &block) = { :access_token_path => '/oauth/access_token', :authorize_url => 'https://api-user.netflix.com/oauth/login', :request_token_path => '/oauth/request_token', :site => 'http://api.netflix.com', } super(app, :netflix, consumer_key, consumer_secret, , , &block) end |
Instance Method Details
#auth_hash ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/omniauth/strategies/oauth/netflix.rb', line 40 def auth_hash OmniAuth::Utils.deep_merge(super, { 'uid' => user_hash['user']['user_id'], 'user_info' => user_info, 'extra' => { 'user_hash' => user_hash['user'], }, } ) end |
#request_phase ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/omniauth/strategies/oauth/netflix.rb', line 22 def request_phase request_token = consumer.get_request_token(:oauth_callback => callback_url) session['oauth'] ||= {} session['oauth'][name.to_s] = {'callback_confirmed' => request_token.callback_confirmed?, 'request_token' => request_token.token, 'request_secret' => request_token.secret} r = Rack::Response.new if request_token.callback_confirmed? r.redirect(request_token.( :oauth_consumer_key => consumer.key )) else r.redirect(request_token.( :oauth_callback => callback_url, :oauth_consumer_key => consumer.key )) end r.finish end |
#user_hash ⇒ Object
62 63 64 |
# File 'lib/omniauth/strategies/oauth/netflix.rb', line 62 def user_hash @user_hash ||= MultiJson.decode(@access_token.get("http://api.netflix.com/users/#{@access_token.params[:user_id]}?output=json").body) end |
#user_info ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/omniauth/strategies/oauth/netflix.rb', line 52 def user_info user = user_hash['user'] { 'nickname' => user['nickname'], 'first_name' => user['first_name'], 'last_name' => user['last_name'], 'name' => "#{user['first_name']} #{user['last_name']}" } end |