why it is needed to pass auth_token in rails api for authentication? -
i have rails app serves api using devise authetication, far rails application concerned authentication goes fine. in case of rails api, why need pass auth_token.looks passing auth_token need customizing of devise controller seems pain.passing auth_token in request body using rest client allows me signin via post method dont find response. need customize devise controllers ?
need help thanks,
do not want append :auth_token
post/put
parameters on client side send token request header.
this how can it-
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
and auth key devise set api key like-
config.token_authentication_key = :api_key
you can utilize custom strategy back upwards token http header authentication in devise this
ruby-on-rails-3 ruby-on-rails-3.1 ruby-on-rails-3.2
No comments:
Post a Comment