nuclearsandwich / cage

A Faraday Cage for your HTTP Interactions.
http://blog.nuclearsandwich.com/cage
4 stars 2 forks source link

auth support #1

Closed andrew-conway closed 11 years ago

andrew-conway commented 12 years ago

To use this with amee.com some kind of auth support is needed, see http://www.amee.com/developer/docs/ch02.php#authentication

nuclearsandwich commented 12 years ago

Yep, I need to write more on the subject for certain but anything Faraday can do, Cage can do. My old util scripts had opinionated authentication functions, but I want to suffer (and get feedback from people) before I figure out what makes a sensible authentication pattern. It can be done and will be made easier when I add support for a config file, which ought to be later today...

nuclearsandwich commented 12 years ago

So I found out Faraday has really easy HTTP Basic and Token-based Auth support and just expose that directly as of version 0.1.1 (which is now released.)

So to connect to AMEE you could set the following in a .cagerc.rb:

# .cagerc.rb
set :prefix, :https
set :domain, "stage.amee.com"
set :prefix,  "data/transport/defra"
basic_auth "login", "password"

Then from the terminal:

]-> get "route/drill", :type => "great+circle+route"
#=>
Status: 200 OK
...
andrew-conway commented 12 years ago

Excellent. Will give it a play later today with admittedly ropey ruby skills.