Recently, I needed to write an API to work with an iPhone application. I used Clearance for authentication. Unfortunately, it doesn’t support HTTP Basic Authentication out of the box, which made it difficult to use in an API.

I found this issue with a patch that worked. However, the Thoughtbot guys said that Rack::Auth::Basic should be used instead. No examples were provided.

I tried for a few days to get things to work with Rack and ended up using that patch.

Today I decided to take another look at this. I found a cached slideshow on Google that had the info I needed to make an API using a Sinatra app as a Rails Metal.

This is basically how I got HTTP Basic Auth working with Clearance:

Hope it helps someone else having this problem.