Devise API authentication [closed]

There is a devise configuration called :token_authenticatable. So if you add that to the devise method in your “user”, then you can authenticate in your API just by calling

"/api/v1/recipes?qs=sweet&auth_token=[@user.auth_token]"

You’ll probably want this in your user as well:

before_save :ensure_authentication_token

UPDATE (with API authorization code)

The method you’re looking for are:

resource = User.find_for_database_authentication(:login=>params[:user_login][:login])
resource.valid_password?(params[:user_login][:password])

here’s my gist with a full scale JSON/API login with devise

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)