JSON parses a remote URL that requires a username and password

I have a url that points to JSON output, however this url requires a username and password through a standard apache authentication field. I tried to access this url from my rails controller as follows:

result = JSON.parse(open("http://user: pass@myurl.com /json").read) 

However, it does not work. I have on top of my controller the following:

 require 'open-uri' require 'json' 

I just get the error message ArgumentError, userinfo not supported. [RFC3986] ArgumentError, userinfo not supported. [RFC3986]

+7
source share
1 answer

try entering the password and user as an additional option

  open("http://...", :http_basic_authentication=>[user, password]) 
+7
source

All Articles