Sign In (Login)

/db/login

A user login will login a user into the backend (database) and return a session token. A session token is then passed with other APIs to do actions on behalf of this user.

Parameter

Required

Description

username

Yes

User username.

password

Yes.

User password.

The sessionToken should be saved to access the user information in subsequent requests. You can save the token in browser's local storage.

Only the sessionToken and _id parameters will be returned in the response after successful authentication. If you want to retrieve custom fields (as email) that were created in Users collection you should send second request after authentication.

To change the sessionToken lifetime, go to Database > Settings and specify session timeout you need.

Example

curl -X GET \
-H "X-Appery-Database-Id: 57928860e4b00ef864f3dc24" \
-G --data-urlencode 'username=amy' \
   --data-urlencode 'password=123' \
   https://api.appery.io/rest/1/db/login
{
    "_id": "5792b0c9e4b00ef864f3dc59",
    "sessionToken": "1f54265f-ef5b-4b96-8163-01e4840a3915"
}