Devise Authentication using cURL

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.

Answers


This works for me :

curl -XPOST -v -H 'Content-Type: application/json' http://domain/api/v1/auth/sign_in -d '{"email": "email@domain.com", "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@domain.com

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@domain.com" http://domain/api/v1/auth/validate_token

The result :

{"success":true,"data":{"id":3,"provider":"email","uid":"email@domain.com","firstname":null,"lastname":null,"email":"email@domain.com"}}

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": "some_user@nowhereville.org", "password": "OpenSecret" }}'

This is Devise 3.5.4.


Need Your Help

Flex: Possible to run multiple instances of a Flex application, each in a different browser window?

actionscript-3 flex flex4

Does a Flex application (by default) enable a user to log in more than once, each time using a new browser window or tab, and not run into any shared memory problems? That is, since it's the same

How to layout for a CSS web directory in a web project

css jsp css3 web

Right now, I want to make a web page interface can be obtained from a number of other sites such as translate.google.com or bbc.com. I use firebug to get the css distribution (css class, div) of el...