LIFX Cloud API Authentication

LIFX makes some excellent Wi-Fi light bulbs and LED strips. Right after I got my first light from LIFX, I wanted to control those lights from an API and make a cool light fixture for my house.

Outside Light with a LIFX Light Bulb

LIFX lets you control the lights with the LIFX Cloud API. The only thing stopping you is the authentication token. The token will be needed to send API requests to the LIFX Cloud API to leverage all of the commands in the HTTP REMOTE CONTROL API. All requests require an OAuth 2 access token.

How to get your LIFX Bearer Token

To get your access token for LIFX, go to: https://cloud.lifx.com/, sign in with the same account that you registered your lights, and click Settings. Under Personal access tokens, click GENERATE NEW TOKEN, enter a label, and click Generate. This will generate a new token that you can use for the LIFX Cloud API. Caution thought. This will be the last time that you see this token. If you lose it, you will have to generate a new API key.

How to use the LIFX Access Token

I recommend using the LIFX token in the HTTP authorization header. It is pretty easy to do. Here’s an example in Python.


import requests


token = "[[app:Token]]"

headers = {
    "Authorization": "Bearer %s" % token,
}

response = requests.get('https://api.lifx.com/v1/lights/all', headers=headers)

Have fun and build some cool integrations with the LIFX Cloud API!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.