Devise Authentication Token

Posted on 07 Oct 2011 by Eric Oestrich

I started using the devise authentication token for a project recently and was confounded on how to get the token from the client’s perspective. After fiddling with different ways, I finally found that adding :authentication_token to attr_accessible let’s it slide through the post to sign_in.

class User
  attr_accessible :authentication_token
end


    curl -d "user[email]=eric@example.com&user[password]=password" 
    http://example.com/users/sign_in.json


    {"authentication_token":"RxYA7tzybe8E3H4q1zvb",
    "email":"eric@example.com"}
comments powered by Disqus
Creative Commons License
This site's content is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License unless otherwise specified. Code on this site is licensed under the MIT License unless otherwise specified.