How to get the Netflix OAuth API to use my callback?

I have a simple Rails app that I'm trying to use the Netflix API to access some of my subscriber data, such as my history and queue. My problem is that no matter what I do, Netflix will not use my oauth_callback URL, but instead redirects me to the Netflix site after I authorize the application with my user credentials.

Here is the controller code that makes the Netflix API request

 class ExportController < ApplicationController def export consumer = OAuth::Consumer.new( ENV['NETFLIX_KEY'],ENV['NETFLIX_SECRET'], :site => "http://api.netflix.com", :request_token_url => "http://api.netflix.com/oauth/request_token", :access_token_url => "http://api.netflix.com/oauth/access_token", :authorize_url => "https://api-user.netflix.com/oauth/login" ) request_token = consumer.get_request_token session[:request_token]=request_token session[:request_token_secret]=request_token.secret url = request_token.authorize_url( :oauth_callback => "http://#{ENV['OAUTH_CALLBACK_DOMAIN']}/export_callback/", :oauth_consumer_key => ENV['NETFLIX_KEY'], :application_name => ENV['APPLICATION_NAME'] ) redirect_to url end def export_callback @request_token=OAuth::RequestToken.new(session[:request_token],session[:request_token_secret]) @access_token = @request_token.get_access_token(:oauth_verifier => params[:oauth_verifier]) end end 

The controller is correctly redirected to the site https://api-user.netflix.com/oauth/login , while all parameters are correctly set. I get a Netflix login / authorization page.

Netflix Link Account page

However, if I look at the source of this page, I see that the oauth_callback field oauth_callback set to oob

  <input type="hidden" name="oauth_callback" value="oob"/> 

I checked a few different ways, and I set the oauth_callback parameter the same way as Netflix Authentication Walkthrough . In fact, when I go through the walkthrough and put my callback in my area, it actually redirects back to my rails application.

So my question is, does anyone know how to make Netflix respect my oauth_callback field?

edit:

 https://api-user.netflix.com/oauth/login?oauth_callback=http%3A%2F%2Fnetflix.dev%2Fexport_callback%2F&oauth_consumer_key=[REMOVED]&oauth_nonce=631831&oauth_timestamp=1321458391&application_name=[REMOVED]&oauth_token=[REMOVED] 

You can set oauth_callback=http%3A%2F%2Fnetflix.dev%2Fexport_callback%2F , which is the route for my local rails application.

edit2:

I use oauth (0.4.5) and rails (3.1.0) and ruby-1.9.2-p290 [ x86_64 ] on Mac OS X 10.6.8.

+6
source share
2 answers

oob , which in form probably refers to β€œout of bounds”. The problem is this:

 request_token = consumer.get_request_token 

Netflix forces you to pass the callback URL when you receive the request token, and checks the URL on the login page. In your case, if you change it to:

 request_token = consumer.get_request_token( :oauth_callback => "http://#{ENV['OAUTH_CALLBACK_DOMAIN']}/export_callback/" ) 

Everything should work from now on, and the form will receive this value. I checked your code and got the same oob and then added the change and it gave the correct value in the form.

+1
source

Try Netflix Authentication Walk-Through and see if it works for your account? it worked for me using firefox. (I also copied and pasted the URL into IE then and redirected accordingly). Then you should try to compare the url with the pass with the url you are generating and fix the problem.

-1
source

Source: https://habr.com/ru/post/900917/


All Articles