{"__v":3,"_id":"55f28173f9f3991900f38a17","category":{"__v":1,"_id":"55f28172f9f3991900f38a15","pages":["55f28173f9f3991900f38a17","55f28173f9f3991900f38a18","55f28173f9f3991900f38a19","55f28173f9f3991900f38a1a","55f28173f9f3991900f38a1b","55f28173f9f3991900f38a1c"],"project":"54ebb40d6423300d003672c0","version":"55f28172f9f3991900f38a13","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-06-17T04:27:26.544Z","from_sync":false,"order":1,"slug":"overview","title":"Overview"},"project":"54ebb40d6423300d003672c0","user":"557e2561eb75d80d00af3dab","version":{"__v":2,"_id":"55f28172f9f3991900f38a13","project":"54ebb40d6423300d003672c0","createdAt":"2015-09-11T07:23:30.065Z","releaseDate":"2015-09-11T07:23:30.065Z","categories":["55f28172f9f3991900f38a14","55f28172f9f3991900f38a15","55f28172f9f3991900f38a16","55f66acb297b37170058accb"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1"},"updates":["5620f09ab244890d001868dc"],"next":{"pages":[],"description":""},"createdAt":"2015-06-17T04:27:46.162Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":0,"body":"All requests require an OAuth 2 access token. You can generate an access token in your [account settings](https://cloud.lifx.com/settings). Take care to keep access tokens private as they grant remote access to your lights.\n\nAuthenticate with HTTP Basic Authentication or the HTTP Authorization header. When using HTTP Basic Authentication the access token is the username and the password may be left blank. Bad access tokens will be rejected by responding with a `401 Forbidden` status code.\n[block:callout]\n{\n  \"type\": \"danger\",\n  \"body\": \"All requests must be made over HTTPS. Requests made to the HTTP endpoint will be rejected with a `426 Upgrade Required` status code indicating that the connection must be remade using HTTPS to continue.\",\n  \"title\": \"HTTPS Requests Only\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"HTTP Authorization Header\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"curl -H \\\"Authorization: Bearer [[app:Token]]\\\" \\\"https://api.lifx.com/v1/lights/all\\\"\",\n      \"language\": \"curl\"\n    },\n    {\n      \"code\": \"<?php\\n\\n$link = \\\"https://api.lifx.com/v1/lights/all\\\";\\n$authToken = \\\"[[app:Token]]\\\";\\n$ch = curl_init($link);\\n$headers = array('Authorization: Bearer ' . $authToken);\\ncurl_setopt($ch, CURLOPT_HTTPHEADER, $headers);\\n$response = curl_exec($ch);\\n\\n?>\\n\",\n      \"language\": \"php\"\n    },\n    {\n      \"code\": \"import requests\\n\\ntoken = \\\"[[app:Token]]\\\"\\n\\nheaders = {\\n    \\\"Authorization\\\": \\\"Bearer %s\\\" % token,\\n}\\n\\nresponse = requests.get('https://api.lifx.com/v1/lights/all', headers=headers)\",\n      \"language\": \"python\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"HTTP Basic Authentication\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"curl -u \\\"[[app:Token]]:\\\" \\\"https://api.lifx.com/v1/lights/all\\\"\",\n      \"language\": \"curl\"\n    },\n    {\n      \"code\": \"<?php\\n\\n$link = \\\"https://api.lifx.com/v1/lights/all\\\";\\n$authToken = \\\"[[app:Token]]\\\";\\n$ch = curl_init($link);\\ncurl_setopt($ch, CURLOPT_USERPWD, $authToken . \\\":\\\");\\n$response = curl_exec($ch);\\n\\n?>\",\n      \"language\": \"php\"\n    },\n    {\n      \"code\": \"import requests\\n\\ntoken = \\\"[[app:Token]]\\\"\\n\\nresponse = requests.get('https://api.lifx.com/v1/lights/all', auth=(token, ''))\\n\",\n      \"language\": \"python\"\n    }\n  ]\n}\n[/block]\n## OAuth Access\n\nLIFX is currently exploring providing OAuth application access to select third parties. This enables your application to get an access token for your users in an automated manner. If you would like to participate in this program please email us at developer:::at:::lifx.com for consideration. Please include the following information:\n\n* Your name and contact details\n* The application you will be integrating with LIFX\n* How OAuth access will improve your integration","excerpt":"Proving that you have access to the right account","slug":"authentication","type":"basic","title":"Authentication"}

Authentication

Proving that you have access to the right account

All requests require an OAuth 2 access token. You can generate an access token in your [account settings](https://cloud.lifx.com/settings). Take care to keep access tokens private as they grant remote access to your lights. Authenticate with HTTP Basic Authentication or the HTTP Authorization header. When using HTTP Basic Authentication the access token is the username and the password may be left blank. Bad access tokens will be rejected by responding with a `401 Forbidden` status code. [block:callout] { "type": "danger", "body": "All requests must be made over HTTPS. Requests made to the HTTP endpoint will be rejected with a `426 Upgrade Required` status code indicating that the connection must be remade using HTTPS to continue.", "title": "HTTPS Requests Only" } [/block] [block:api-header] { "type": "basic", "title": "HTTP Authorization Header" } [/block] [block:code] { "codes": [ { "code": "curl -H \"Authorization: Bearer [[app:Token]]\" \"https://api.lifx.com/v1/lights/all\"", "language": "curl" }, { "code": "<?php\n\n$link = \"https://api.lifx.com/v1/lights/all\";\n$authToken = \"[[app:Token]]\";\n$ch = curl_init($link);\n$headers = array('Authorization: Bearer ' . $authToken);\ncurl_setopt($ch, CURLOPT_HTTPHEADER, $headers);\n$response = curl_exec($ch);\n\n?>\n", "language": "php" }, { "code": "import requests\n\ntoken = \"[[app:Token]]\"\n\nheaders = {\n \"Authorization\": \"Bearer %s\" % token,\n}\n\nresponse = requests.get('https://api.lifx.com/v1/lights/all', headers=headers)", "language": "python" } ] } [/block] [block:api-header] { "type": "basic", "title": "HTTP Basic Authentication" } [/block] [block:code] { "codes": [ { "code": "curl -u \"[[app:Token]]:\" \"https://api.lifx.com/v1/lights/all\"", "language": "curl" }, { "code": "<?php\n\n$link = \"https://api.lifx.com/v1/lights/all\";\n$authToken = \"[[app:Token]]\";\n$ch = curl_init($link);\ncurl_setopt($ch, CURLOPT_USERPWD, $authToken . \":\");\n$response = curl_exec($ch);\n\n?>", "language": "php" }, { "code": "import requests\n\ntoken = \"[[app:Token]]\"\n\nresponse = requests.get('https://api.lifx.com/v1/lights/all', auth=(token, ''))\n", "language": "python" } ] } [/block] ## OAuth Access LIFX is currently exploring providing OAuth application access to select third parties. This enables your application to get an access token for your users in an automated manner. If you would like to participate in this program please email us at developer@lifx.com for consideration. Please include the following information: * Your name and contact details * The application you will be integrating with LIFX * How OAuth access will improve your integration