-
Notifications
You must be signed in to change notification settings - Fork 0
API: Authentication
jorge-d edited this page Apr 19, 2013
·
1 revision
You must send a POST /users/sign_in
with the correct parameters (email and password) to sign up.
Example:
curl -X POST \
-H "Accept: application/json" \
-d 'user[email][email protected]&user[password]=toto42' \
http://localhost:3000/users | json
Will have the following input:
{
"response": "ok",
"id": 3,
"auth_token": "tkxznjbSHTC2gKMCzfvG"
}
If an error occurs, the output will this kind of format format:
curl -X POST \
-H "Accept: application/json" \
-d '' \
http://localhost:3000/users | json
{
"error": {
"email": [
"can't be blank"
],
"password": [
"can't be blank"
]
}
}
You must send a POST /users/sign_in
with the correct parameters (email and password) to receive your auth_token.
Example:
curl -X POST \
-H "Accept: application/json" \
-d 'user[email][email protected]&user[password]=toto42' \
http://localhost:3000/users/sign_in
Will have the following output:
{
"response": "ok",
"nickname": "keny",
"first_name": "Dimitri",
"last_name": "Jorge",
"auth_token": "sYcyvuHUopjT46iMhkU5"
}
You MUST use the 'auth_token' returned in all the future requests !