Skip to content

POST /api/v3/lightning/device-request/{lcuid}/check-for-device

Summary

GET /lightning/device-request/{lcuid}/check-for-device

Description

Check if a device has authenticated with a device code

Using the lcuid of the device request, and the token you received when calling /lightning/device-requests/request you can check to see if the device has been setup yet. See /lightning/device-requests/request

This endpoint will return one of of the following responses

  • 200: The device has been created and you can move on to auth and configuring
    • The response will include the lcuid of the device and the bot user token and secret that you can use for auth
  • 202: The device has not yet been created, keep checking though
  • 422: The token is invalid or expired

Note that calling this endpoint repeatedly, after a device has been created, will regenerate a new token and secret for the bot user.

Tags: lightning

Parameters

Header Parameters

Name Type Required Description Example
Content-Type string ✓ Yes application/json
Accept string ✓ Yes application/json
AppIdV3 string ✓ Yes LCUID-LAP-********-****-****-****-************

Request Body

Required: Yes

Content Type: application/json

Schema

Type: object

Required fields: token

Properties:

  • token (string) (required): The token you received when you requested the device code.
  • auto_attach_to_lcuid (string): If you want to attach to an existing lightning device Pass the lcuid of that device here.

Responses

Response: 200

Description: Device Ready

Content Type: application/json

Schema

Type: object

Properties:

  • success (boolean): true if we have a device, false if not
  • lightning_device_lcuid (string): The new lcuid of this device
  • bot_user_token (string): The token of the bot user that this device should use
  • bot_user_secret (string): The secret of the bot user that this device should use
Example Response
{
    "success": true,
    "lightning_device_lcuid": "LCUID-LD-c8661ab3-9fc3-4bcb-a080-ce1e7f2f7580",
    "bot_user_token": "JNwUgmgSXBzb8yMoDQ13S0iotgjg1LxqAjYct4LihHF2ydLELFs3nakYhmoJ",
    "bot_user_secret": "GdGzDlW6txuHiQSyAXy4Nod80iBAswnTGNS1yxGl7ELsKNwnwGRZ7gc2dv6JHD0t"
}

Response: 202

Description: Pending Device Setup

Content Type: application/json

Schema

Type: object

Properties:

  • success (boolean): true if we have a device, false if not
  • device_exists (boolean)
  • device_status (string)
Example Response
{
    "success": false,
    "device_exists": false,
    "device_status": null
}

Response: 422

Description: Token Invalid or Expired

Content Type: application/json

Schema

Type: object

Properties:

  • ok (boolean)
  • http_code (integer)
  • code (string)
  • message (string)
  • data (string)
  • lucore_error_response (boolean)
Example Response
{
    "ok": false,
    "http_code": 422,
    "code": "Token is invalid or expired",
    "message": "token_invalid_or_expired",
    "data": null,
    "lucore_error_response": true
}

Example Implementations

Bash (cURL)

curl --request POST \
  --url "https://api.lucit.app/api/v3/lightning/device-request/{lcuid}/check-for-device" \
  --header "Content-Type: application/json" \
  --header "Accept: application/json" \
  --header "AppIdV3: LCUID-LAP-********-****-****-****-************"

JavaScript (Fetch API)

const url = "https://api.lucit.app/api/v3/lightning/device-request/{lcuid}/check-for-device";

const headers = {
  "Content-Type": "application/json",
  "Accept": "application/json",
  "AppIdV3": "LCUID-LAP-********-****-****-****-************"
};

fetch(url, {
  method: "POST",
  headers: headers
})
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));

PHP (Guzzle)

<?php

require_once 'vendor/autoload.php';

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.lucit.app/api/v3/lightning/device-request/{lcuid}/check-for-device', [
  'headers' => [
    'Content-Type' => 'application/json',
    'Accept' => 'application/json',
    'AppIdV3' => 'LCUID-LAP-********-****-****-****-************',
  ]
]);

$body = $response->getBody();
$data = json_decode($body, true);
print_r($data);

Python (Requests)

import requests
import json

url = "https://api.lucit.app/api/v3/lightning/device-request/{lcuid}/check-for-device"

headers = {
  "Content-Type": "application/json",
  "Accept": "application/json",
  "AppIdV3": "LCUID-LAP-********-****-****-****-************"
}

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

← Back to lightning index | Back to main index