I need to use token based authentication in a Rails 3.1 API in conjunction with the most recent version of devise. No problem so far.
Now I do not want to append my :au
I had the same need and came up with this solution:
class YourController < ApplicationController
prepend_before_filter :get_api_key
before_filter :authenticate_user!
private
def get_api_key
if api_key = params[:api_key].blank? && request.headers["X-API-KEY"]
params[:api_key] = api_key
end
end
end
Note I have my devise Devise.token_authentication_key
set to api_key
.
config.token_authentication_key = :api_key