1

I'm using: Rails 3.2, Mac OS X Mountain Lion

I have this Active Resource Model:

Class Model < ActiveResource::Base
   self.site = "http://localhost:3000"
end

Problem is, the site I am connecting to has an authentication. It checks for parameters api_key and api_secret so that it knows who it's talking to.

My question is: How do I pass parameters in active resource? I tried the "http://api_key:api_secret@localhost:3000" way and the "http://localhost:3000?api_key=1234&api_secret=1234" way but both didn't work.

Thanks a lot.

Aldrin Dela Cruz
  • 205
  • 1
  • 4
  • 15

1 Answers1

0

Try set user as API key and password as API secret:

Class Model < ActiveResource::Base
   self.site = "http://localhost:3000"
   self.user = "1234"      # API key
   self.password = "1234"  # API secret
end
David Vass
  • 135
  • 7
  • thank your answer. How to read user/password from console, I do not want write those secrete information in source code. – gzh Nov 10 '16 at 11:05
  • To be honest, I don't know. I would try getting cli arguments in regular way via ARGV object. But truth is that when you'll be running your code in production, it will have to be hardcoded somewhere anyway, wether it is your ruby code or bash script that will run your app. – David Vass Nov 27 '16 at 14:52