Search code examples
rubyhttp-headershttp-authentication

Using Ruby to authenticate to Azure (HTTP Header authentication)?


Since the Google Search API has been deprecated, I'd like to use the Bing Search API (now a Windows Azure API) in my Ruby apps.

However, Azure has a strange authentication pattern where you build a query URI, paste it into a browser, pass the key into the password box of the standard HTTP authentication box, and make POST to see the results. I assume this generates a signature and passes it in the header somehow. I'd like to do the complete process in Ruby and skip the browser portion if possible.

I found one example in the source of an obscure Windows Azure storage gem, but I can't figure out how tthey're building the signature and make the call. Is there a simple way to do basic HTTP auth in Ruby?


Solution

  • I went ahead and used Faraday's built in basic authentication scheme like so:

    connection = Faraday.new "http://api.something.com/1/dudez"
    connection.basic_auth "username" "password"
    connection.get