OAuth with the third-party device cloud
When your SmartApp Connector receives the device list from the third-party device cloud with a GET request, the SmartApp Connector should then issue requests to create a device in SmartThings Cloud for each device in that list. This step must occur in the PAGE phase of the CONFIGURATION lifecycle phase, while the SmartApp Connector is being installed.
Here is an example of a request body showing the PAGE settings
for the authentication request into the LIFX cloud.
"settings": [
{
"id": "LIFX OAuth",
"name": "LIFX OAuth",
"description": "Authentication request into the LIFX cloud",
"urlTemplate": "https://cloud.lifx.com/oauth/authorize?client_id=$clientId&scope=remote_control:all&response_type=code&redirect_uri=https%3A%2F%2Fapi.smartthings.com%2Foauth%2Fcallback",
"required": true,
"type": "OAUTH"
}
]
The LIFX cloud will respond to SmartThings Cloud with a urlPath
string that contains the necessary authorization and tokens. SmartThings Cloud will then call the SmartThings Connector with this urlPath
with the lifecycle
of OAUTH_CALLBACK
.
https://api.smartthings.com/oauth/callback
. However, in the above urlTemplate
, the redirect_uri
must have the URL encoded OAuth callback url: https%3A%2F%2Fapi.smartthings.com%2Foauth%2Fcallback
.
Create the device in SmartThings Cloud
When your SmartApp Connector receives a list of devices from the third-party device cloud, the next step is to create these devices in SmartThings Cloud. Note that these devices are created at the user's Location in SmartThings Cloud.
Here is an example of a POST request body to create a device, and the response back from SmartThings Cloud.
{
"label": "Living room light",
"locationId": "0c0b935d-0616-4441-a0bf-da7aeec3dc0a",
"app": {
"profileId": "6f5ea629-4c05-4a90-a244-cc129b0a80c3",
"installedAppId": "6f5ea629-4c05-4a90-a244-cc129b0a80c3",
"externalId": "Th13390"
}
}