I want to test my rails web service using cURL, yet so far I could only do it while deactivating before_filter :authenticate_user!. But I’d like to log in a priori and then create, destroy etc.
I saw that with cURL you can authenticate and save the session info in a cookie, that you use for your following requests, yet I couldn’t make it work with Devise: in my scenario, the user logs in using an email/password combination, so I’m trying:
curl \ -X POST \ -d 'email=email@example.com&password=password' \ -c cookie \ http://localhost:3000/users/sign_in > out
and I get: ActionController::InvalidAuthenticityToken in Devise/sessionsController#create
Could somebody give me an idea / an example?
Thanks!
This works:
Authenticate:
curl -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -X POST http://localhost:3000/users/sign_in \ -d "{'user' : { 'email' : 'test@example.com', 'password' : 'password'}}" \ -c cookieShow: