Hi everyone
I''m learning Ruby on Rails and wanted to perform oAuth as follows for
a third party API. But I get an error as follows:
wrong status line: "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML
2.0//EN
\">"
//Code snippet
require ''net/https''
require ''uri''
class UsersController < ApplicationController
def auth
@client_id = params[:client_id]
@auth_url = "https://url/oauth/authorize?
client_id=#{@client_id}"
url = URI.parse(@auth_url )
req = Net::HTTP::Post.new(url.path)
res = Net::HTTP.start(url.host, url.port) {|http|
http.request(req)}
@output = res.body
render :text => @output.inspect
end
end
Any help to proceed is much appreciated.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Matt Jones
2012-May-25 12:19 UTC
Re: Newbie question - how to resolve ''wrong status line'' error
On Thursday, 24 May 2012 06:13:42 UTC-4, iDev wrote:> > Hi everyone > > I''m learning Ruby on Rails and wanted to perform oAuth as follows for > a third party API. But I get an error as follows: > > wrong status line: "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN > \">" > > > //Code snippet > require ''net/https'' > require ''uri'' > > class UsersController < ApplicationController > > def auth > @client_id = params[:client_id] > @auth_url = "https://url/oauth/authorize? > client_id=#{@client_id}" > >Looks like you''ve hit this issue: http://stufftohelpyouout.blogspot.com/2010/05/how-to-fix-nethttpbadresponse-wrong.html Adding the use_ssl option, as that example does, should sort things out. BTW, you may want to look into using one of the existing OAuth gems - there aren''t many good reasons to be re-inventing this particular wheel. --Matt Jones -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/sK8WN5R-_R0J. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.