AUTH

Use the Auth API to:

  • Log in to the project
  • Retrieve an authentication token
  • Validate an authentication token
  • Refresh an authentication token
  • Log out of the project

HTTP Headers

The HTTP headers used to access all RTLS APIs are listed below. Use the Auth API to set the headers for X-User-Email and X-User-Token.

Header Name Example Value Description
X-User-Email admin@example.com Email address of the user performing HTTP requests to the API.
X-User-Token Drv3yU7PdyqUMtr89erZ Token allowing the user access to the API.
X-User-Project OfOgUA4kTs2HrmYYlFw6Jg Project identifier. Value of the project.uid field.
Set header X-USER-EMAIL

Send a request to log in. Using the email address returned in the response, set: X-USER-EMAIL = data.email

Set header X-USER-TOKEN

Send a request to log in. Using the authentication token returned in the response, set: X-USER-TOKEN = data.token

Set header X-USER-PROJECT

Send a request to get projects using GET api/projects/ described in the Projects API. You must send this request with headers X-USER-EMAIL and X-USER-TOKEN already set. Using the project UID returned in the response, set: X-USER-PROJECT = projects[i].uid

Auth Endpoints

Functionality Method Endpoint
log in POST api/auth/log_in
validate POST api/auth/validate_token
refresh token POST api/auth/refresh_token
log out POST api/auth/log_out

Endpoints

Log in

POST api/auth/log_in

Retrieves authentication token for user.

Your login credentials are created in the SiteWise web portal.

Request Fields

Field Required/Optional Type Description
email required string Your email credential used to log in.
password required string Your password used to log in.

Response Fields

Field Description
success Returns whether the login attempt was successful:
  • true
  • false
email The email used to log in.
token An authentication token to identify the current user.
company A JSON object with information about the company associated with the user.
company.id The identifier of the company in the server.
company.name The company name.
company.user_params User-defined company parameters.
company.uid The unique identifier of the company.
company.role_uid Reserved field.
company.scope Reserved field.
company.role Reserved object.
isSuperAdmin Returns whether the current user is a super administrator user:
  • true
  • false
isSystemUser Returns whether the current user is project user (without administrator privileges):
  • true
  • false
isCompanyAdmin Returns whether the current user is a company administrator user:
  • true
  • false
sign_in_count Returns the number of successful logins.

Example Request

{
    "email": "user@example.com",
    "password": "Drv3yU7PdyqUMtr89erZ"
}

Example Response

{
    "success": true,
    "data": {
        "email": "user@company.com",
        "token": "Vwp7i3o1234Z4MqycAo_",
        "company": {
            "id": 283,
            "name": "RPP Boston",
            "taggings_count": 0,
            "user_params": {
                "color": "#ff5b5b",
                "website": "",
                "phone": "12345678900",
                "tag_allocation": false,
                "address": ""
            },
            "uid": "Kr5G4eydvoRz4YZWCStzsQ",
            "scope": "Y",
            "role_uid": "XJv7AtqCJfFHtDPJzyUF5d",
            "role": {
                "id": 3,
                "name": "Subcontractor",
                "uid": "XJv7AtqCJfFHtDPJzyUF5d",
                "display_name": "Company"
            }
        },
        "isSuperAdmin": false,
        "isSystemUser": false,
        "isCompanyAdmin": true,
        "sign_in_count": 386
    }
}

Errors

Error Status Error Type Error Body Description
401 Unauthorized {"success":false,"error":"Unable to log in. Check your email address and your password."} The wrong email or password was submitted, or the token or user was not found.
422 Unprocessable entity {"message":"Credentials are invalid"} The wrong email or password was submitted, or the token or user was not found.
401 Unauthorized {"message":"Unable to log in. Check your email address and your password."} The wrong email or password was submitted.
423 Locked {"message": "The user is disabled "} The user was disabled.

Validate

POST /api/auth/validate_token

Validate an existing authentication token. Returns a JSON object with status of 200.

You must log in first to retrieve a token. Use the headers to send a request to validate your token.

Request Fields

Field Required/Optional Type Description
email required string The email to log out.
token required string The token to log out.
onBehalfToken optional string The additional token for user that enter to lower scope (company admin in project scope).

Request Example

{
    "email": "redpoint_positioning_impersonate@g6g66uJfQBOnY9pm-_H66g",
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHBpcmVzSW4iOjEyMDAsInVzZXIiOnsiZW1haWwiOiJyZWRwb2ludF9wb3NpdGlvbmluZ19pbXBlcnNvbmF0ZUBnNmc2NnVKZlFCT25ZOXBtLV9INjZnIiwidWlkIjoiMUFyUDdBWktUYW1ZczY2YjFjTmVfQSIsImF1dGhlbnRpY2F0aW9uX3Rva2VuIjoiZXlKaGJHY2lPaUpJVXpJMU5pSXNJblI1Y0NJNklrcFhWQ0o5LmV5SmxlSEJwY21WelNXNGlPakV3TXpZNE1EQXdMQ0pwWkNJNklteFNNa1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BWktUYW1ZczY2YjFjTmVfQSIsImF1dGhlbnRpY2F0aW9uX3Rva2VuIjoiZXlKaGJHY2lPaUpJVXpJMU5pSXNJblI1Y0NJNklrcFhWQ0o5LmV5SmxlSEJwY21WelNXNGlPakV3TXpZNE1EQXdMQ0pwWkNJNklteFNNa1ZtZG1wVFZFNVhUa3Q0WW5CYVgwNVZWVkVpTENKcFlYUWlPakUxT0Rrek5qWTBORGg5Ll9kdU11MVEzM3JRVGxHNnBCSHBZcHBxVU9KdXM5MlQzekJnbnB1Ui1nRTgiLCJhZG1pbiI6MSwiY29tcGFueV91aWQiOiJnNmc2NnVKZlFCT25ZOXBtLV9INjZnIiwic3RhdHVzIjoiQUNUSVZFIn0sImlhdCI6MTU5MjIyMjczM30.117hpAhQGi8-qbBX4AxTULeaoH5XpSToyZI3qLJIMkw",
}

Response Fields

Field Description
success Indicates if the token was successfully validated:
  • true
  • false
data A JSON object with information about the login.
data.email The email used to log in.
data.token An authentication token to identify the current user.

Example Response

{ 
    "success": true, 
    "data": { 
        "email": "admin@example.com",     
        "token": "Drv3yU7PdyqUMtr89erZ" 
    } 
}

Errors

Error Status Error Type Error Body Description
401 Unauthorized {"success":false,"error":"Unable to authenticate"} Invalid token.
423 Locked {"message": "The user is disabled "} The user was disabled.

Refresh token

POST /api/auth/refresh_token

Expire an existing token and obtain a new one. On success, a JSON object is returned with the status 200.

Request Fields

Field Description
email The email used to log in.
token An authentication token to identify the current user. To get a token, see log in.

Response Fields

Field Description
success Indicates if the token was successfully refreshed:
  • true
  • false
data A JSON object with information about the login.
data.email The email used to log in.
data.token A new authentication token to identify the current user.

Example Request

{"email":"user@example.com","token":"pp76TniNb39o6G0mYjQP"}

Example Response

{
    "success": true,
    "data": {
        "email": "user@example.com",
        "token": "Drv3yU7PdyqUMtr89erZ"
    }
}

A new, updated token is included in the response.

Errors

Error Status Error Type Error Body Description
401 Unauthorized {"success":false,"error":"Token expired"} The token was expired and the authentication failed.
401 Unauthorized {"success":false,"error":"Token expired"} An incorrect token was entered and authentication failed.

Log out

POST api/auth/log_out

Log out of your account. A successful request returns a status of 200.

Request Fields

Field Required/Optional Type Description
email required string The email to log out.
token required string The token to log out.

Example Request

{
    "email": "user@example.com",
    "token": "Drv3yU7PdyqUMtr89erZ"
}

Example Response

{
  "success": true,
  "data":{
    "email": "user@example.com"
  }
}

Note: The log out request must include a valid X-User-Token and X-User-Email in the headers.

Errors

Error Status Error Type Error Body Description
401 Unauthorized {"message":"Token expired"} Invalid token was sent in headers.
403 Forbidden {"success":false,"error":"Log out fails"} Incorrect token entered.

results matching ""

    No results matching ""