Difference between revisions of "API:POST /login"

From SoFurry
Jump to: navigation, search
(Request)
 
(2 intermediate revisions by the same user not shown)
Line 7: Line 7:
 
  POST /login
 
  POST /login
 
  {
 
  {
   "email": "bob@example.org",
+
   "username": "bob",
 
   "password": "hunter2"
 
   "password": "hunter2"
 
  }
 
  }
  
= Sample Response =
+
= Response: Success =
  
 
  HTTP 200
 
  HTTP 200
 
  {
 
  {
   "token": "..."
+
  "result": true,
 +
   "token": "1:fd776c3a631eeae849688a618887546d"
 
  }
 
  }
  
 +
If the result is TRUE, then the login was a success. The token it returns should be sent on all future requests, using the <code>X-SoFurry-Token</code> HTTP header.
 +
 +
= Response: Failed Login =
 +
 +
HTTP 422
 +
{
 +
  "result": false,
 +
  "message": "Incorrect username or password"
 +
}
 +
 +
You don't need to display that exact message in your client app. It will fail like this if the email address or password is incorrect, or if the user has not yet been activated.
  
 
[[Category:API]]
 
[[Category:API]]

Latest revision as of 14:25, 15 May 2016

Resource URL

https://api.sofurrybeta.com/login

Request

POST /login
{
  "username": "bob",
  "password": "hunter2"
}

Response: Success

HTTP 200
{
  "result": true,
  "token": "1:fd776c3a631eeae849688a618887546d"
}

If the result is TRUE, then the login was a success. The token it returns should be sent on all future requests, using the X-SoFurry-Token HTTP header.

Response: Failed Login

HTTP 422
{
  "result": false,
  "message": "Incorrect username or password"
}

You don't need to display that exact message in your client app. It will fail like this if the email address or password is incorrect, or if the user has not yet been activated.