Authenticating and Obtaining a Session ID

Before being able to request any data, one needs to authenticate with the API and get a session ID. The session ID can be retrieved either as part of the JSON response, or else as a cookie.

If authentication is not done, further requests will be rejected. If a POST request for a report is done and no authentication has been made, a 401 error code will be returned. If the same request is done using GET, instead of an error, a 302 redirect is returned to the authentication page.

You use the following POST request to authenticate a user by verifying username and password.

POST /auth/login

This authentication request has the following properties.

Request Properties

Property

Description

Request JSON Object

user (string)—The username of your Usage Intelligence user account
password (string)—The corresponding password of your Usage Intelligence user account
useCookies (boolean)—Optional parameter to specify whether the response should set a cookie (if true), or include the session ID as part of the JSON response (if false). Default is false.

Request Headers

Content-Type—Can be set to application/json or text/javascript 
Accept—Should be set to text/javascript 

Response Headers

Content-Type—Will contain text/javascript 

Status Codes

200 OK—OK (no error)
400 Bad Request—Malformed request
403 Forbidden—Wrong credentials supplied

Response JSON Object

status (string)—Contains OK if successful or SYNTAX ERROR or AUTH ERROR.
reason (string)—Present only if status is not OK. Contains error message (reason).
sessionId (string)—Present only if status is OK and useCookies is false. Contains session ID to be used in all further requests.

Example Request

POST /auth/login  HTTP/1.1

Host: api.revulytics.com

Content-Type: application/json

Accept: application/json

 

{

    "user": "testuser@test.com",

    "password": "mypassword1",

    "useCookies": false

}

Example Response

HTTP/1.1 200 OK

Content-Type: application/json

 

{

  "status": "OK",

  "sessionId": "VSB8E2BzSC2eZSJm4QmTpA"

}