From ce52af037661faf0a2c6fb40ed66df562147a13a Mon Sep 17 00:00:00 2001 From: bflorian Date: Tue, 21 Mar 2017 14:15:20 -0700 Subject: [PATCH] DVCSMP-2528 Added app setting for OAuth callback URL --- .../smartthings/lifx-connect.src/lifx-connect.groovy | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/smartapps/smartthings/lifx-connect.src/lifx-connect.groovy b/smartapps/smartthings/lifx-connect.src/lifx-connect.groovy index 974561e..dd17429 100644 --- a/smartapps/smartthings/lifx-connect.src/lifx-connect.groovy +++ b/smartapps/smartthings/lifx-connect.src/lifx-connect.groovy @@ -19,8 +19,15 @@ definition( singleInstance: true) { appSetting "clientId" appSetting "clientSecret" + appSetting "serverUrl" // See note below } +// NOTE regarding OAuth settings. On NA01 (i.e. graph.api), NA01S, and NA01D the serverUrl app setting can be left +// Blank. For other shards is should be set to the callback URL registered with LIFX, which is: +// +// Production -- https://graph.api.smartthings.com +// Staging -- https://graph-na01s-useast1.smartthingsgdev.com +// Development -- https://graph-na01d-useast1.smartthingsgdev.com preferences { page(name: "Credentials", title: "LIFX", content: "authPage", install: true) @@ -35,8 +42,8 @@ mappings { path("/test") { action: [ GET: "oauthSuccess" ] } } -def getServerUrl() { return "https://graph.api.smartthings.com" } -def getCallbackUrl() { return "https://graph.api.smartthings.com/oauth/callback"} +def getServerUrl() { return appSettings.serverUrl ?: apiServerUrl } +def getCallbackUrl() { return "${getServerUrl()}/oauth/callback" } def apiURL(path = '/') { return "https://api.lifx.com/v1${path}" } def getSecretKey() { return appSettings.secretKey } def getClientId() { return appSettings.clientId }