Skip to content

Authentication

Authentication for the Lightbug APIs make use of Bearer tokens in the Authorization header.

API calls that require authentication must have a bearer token submitted as part of the request.

sh
curl -X GET "https://api.lightbug.cloud/apiEndpoint" -H "Authorization: <token>"'

Tokens can be generated from both the v1 and v2 REST APIs, and tokens from either API can be used to authenticate requests to either API.

Tokens might look something like this:

  • aLB1MKbtxLBb02A0fLFUwJ2nLBMaEFeo8ZLB0gHNCTYIGTJ12oBLB0FMlLBjAlLB
  • xLBJhbGciOiJIUzILBiIsILBhjd76IkpXCJ9.eyJle2hs0cy3MjMwMjk1OTjkdhcmcyI6ImdnIiwianRpIjoiZ0luLXNhN3BWYjFTNnhOZFAkchdy2kF2RzlFYzhfV0hlVnJUFUQ0QjN4X3BrbLBvcFh2VUMtX2poM0d0cVlkZ2dvVUUxZ3k0ckg4YTJPNDFxVW8PdUw4OHNPR2hQlkjdbxpWMjU5UE1vb3N5bVFHbmxibW1iYlZRYkNuN2tnRUllTLBLSksyNlNEOEpqbW1qSS15ZjBJSnZHU3NCeWhBekN3R1dwTXhoLBFrcE9VbS1lVkxTb1pwYUlhWkhkQlVycWtlUi1aNE55SnF4SEg4ZmpUaGw1bE81aHZFNVY1lkg890FCTk85anZjMlRRcGdiUGN0dGNazsdfyzBGOFdzIiwibmFtZSI6ImFkYW1AbGllkHRidWcuaW8iLCJzdWIiOjM4MDh9.LBpcVEbm0sywbcPScTg9j54SxdNydJuC_vncrh-fDps

Version 2

Login

POST
/users/login

Login and receive an access token for future requests.
Optionally receive a refresh token for future access token generation.

Request Body

JSON
{
"password": "string",
"refreshable": 0,
"username": "string"
}

Responses

OK
application/json
JSON
{
"expiry": "string",
"refreshToken": "string",
"refreshTokenExpiry": "string",
"token": "string",
"userId": 0
}
Body
{
password
:
string
refreshable
:
0
username
:
string

Samples

cURL
curl -X POST \
'http://localhost:8080/v2/users/login' \
 -H "Content-Type: application/json"
JavaScript
fetch('http://localhost:8080/v2/users/login', {method:'POST',headers:{'Content-Type':'application/json'}})
  .then(response => response.json())
  .then(data => console.log(data));
PHP
<?php
$url = 'http://localhost:8080/v2/users/login';
$method = 'POST';
$headers = [
    'Content-Type' => 'application/json',
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$response = curl_exec($ch);
curl_close($ch);

echo $response;
?>
Python
import requests

url = 'http://localhost:8080/v2/users/login'

headers = {
    'Content-Type': 'application/json'
}

response = requests.post(url, headers=headers)
print(response.json())

Refresh token

POST
/users/refreshToken

Refresh the access token and refresh token that was retrieved during login.

Request Body

JSON
{
"accessToken": "string",
"refreshToken": "string",
"refreshable": 0
}

Responses

OK
application/json
JSON
{
"expiry": "string",
"refreshToken": "string",
"refreshTokenExpiry": "string",
"token": "string",
"userId": 0
}
Body
{
accessToken
:
string
refreshToken
:
string
refreshable
:
0

Samples

cURL
curl -X POST \
'http://localhost:8080/v2/users/refreshToken' \
 -H "Content-Type: application/json"
JavaScript
fetch('http://localhost:8080/v2/users/refreshToken', {method:'POST',headers:{'Content-Type':'application/json'}})
  .then(response => response.json())
  .then(data => console.log(data));
PHP
<?php
$url = 'http://localhost:8080/v2/users/refreshToken';
$method = 'POST';
$headers = [
    'Content-Type' => 'application/json',
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$response = curl_exec($ch);
curl_close($ch);

echo $response;
?>
Python
import requests

url = 'http://localhost:8080/v2/users/refreshToken'

headers = {
    'Content-Type': 'application/json'
}

response = requests.post(url, headers=headers)
print(response.json())

Version 1

Login

POST
/users/login

Parameters

Query Parameters

include

Related objects to include in the response. See the description of return value for more details.

Typestring
formatJSON

Request Body

JSON
{
"username": "string",
"password": "string"
}

Responses

Body (JSON)
application/json
JSON
{
"id": "string",
"ttl": 0,
"scopes": [
"string"
],
"created": "string",
"userId": 0
}
Variables
Key
Value
include
Body
{
username
:
string
password
:
string

Samples

cURL
curl -X POST \
'https://api.lightbug.cloud/api/users/login' \
 -H "Content-Type: application/json"
JavaScript
fetch('https://api.lightbug.cloud/api/users/login', {method:'POST',headers:{'Content-Type':'application/json'}})
  .then(response => response.json())
  .then(data => console.log(data));
PHP
<?php
$url = 'https://api.lightbug.cloud/api/users/login';
$method = 'POST';
$headers = [
    'Content-Type' => 'application/json',
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$response = curl_exec($ch);
curl_close($ch);

echo $response;
?>
Python
import requests

url = 'https://api.lightbug.cloud/api/users/login'

headers = {
    'Content-Type': 'application/json'
}

response = requests.post(url, headers=headers)
print(response.json())