Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSON parse from a Remote URL which requires a username and password

I have a url which points to a JSON output, however this URL requires a username and password through a standard apache pop up authentication box. I have tried to access this URL from my rails controller like the following:

result = JSON.parse(open("http://user:[email protected]/json").read)

However it isn't working. I have the following at the top of my controller:

require 'open-uri'
require 'json'

I just get an error which says ArgumentError, userinfo not supported. [RFC3986]

like image 557
Dave Avatar asked Jan 25 '13 11:01

Dave


1 Answers

try to password and user as additional option

 open("http://...", :http_basic_authentication=>[user, password])
like image 163
Fivell Avatar answered Oct 17 '22 02:10

Fivell