Answer the question
In order to leave comments, you need to log in
How to fix 401 (Unauthorized) error?
I am using gem devise_auth_token for authentication. When I try to login I get a 401 Unauthorized error
Started POST "/auth/sign_in" for 10.12.4.5 at 2018-06-01 11:37:48 +0500
Processing by DeviseTokenAuth::SessionsController#create as JSON
Parameters: {"password"=>"[FILTERED]", "session"=>{"password"=>"[FILTERED]"}}
Unpermitted parameter: :session
Completed 401 Unauthorized in 26ms (Views: 0.7ms | ActiveRecord: 0.0ms)
class ApplicationController < ActionController::API
include DeviseTokenAuth::Concerns::SetUserByToken
before_action :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [:login, :email, :password, :password_confirmation])
devise_parameter_sanitizer.permit(:sign_in, keys: [:login, :password])
devise_parameter_sanitizer.permit(:account_update, keys: [:password, :password_confirmation, :current_password])
end
end
Rails.application.routes.draw do
mount_devise_token_auth_for 'User', at: 'auth'
end
Answer the question
In order to leave comments, you need to log in
Read the logs carefully, they are great in rails.Unpermitted parameter: :session
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question