How can I authenticate my Ruby on Rails Application using cURL from terminal using Devise?
I'm trying:
curl --user email:password http://domain.bla/api/auth/sign_in
And is responding:
The page you were looking for doesn't exist.
This works for me :
curl -XPOST -v -H 'Content-Type: application/json' http://domain/api/v1/auth/sign_in -d '{"email": "[email protected]", "password": "password" }
So I get back the response (something like below, only important part) :
< access-token: lW1c60hYkRwAinzUqgLfsQ
< token-type: Bearer
< client: W_xCQuggzNOVeCnNZbjKFw
< expiry: 1426610121
< uid: [email protected]
Then I can validate the token, using the client and token previously obtained from the above request, I do it like this :
curl -XGET -v -H 'Content-Type: application/json' -H 'access-token: lW1c60hYkRwAinzUqgLfsQ' -H 'client: W_xCQuggzNOVeCnNZbjKFw' -H "uid: [email protected]" http://domain/api/v1/auth/validate_token
The result :
{"success":true,"data":{"id":3,"provider":"email","uid":"[email protected]","firstname":null,"lastname":null,"email":"[email protected]"}}
I found that the login step needed to be wrapped in a user
dictionary, viz:
curl -X POST -v -H 'Content-Type: application/json' \
http://somehost.com/users/sign_in -d \
'{"user" : {"email": "[email protected]", "password": "OpenSecret" }}'
This is Devise 3.5.4.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With