appSettngs


(Martin Verbeek) #1

i need to pass clientID and ClientSecret to external service and i thought i needed to enable oAuth (that gives me a generated clientid and secret) for that so i can access these values via appSettings.clientID.
I have include the appSetting statements in code, but with or without these accessing appSettings.cliengtID and clientSecret gives me nothing back.
What am i missing, or how can i access the clientid and secret in the appSettings


(Todd Wackford) #2

Here you go. Make sure to go into the App Settings of IDE and set the values for the variables.

/**
 *  template
 *
 *  Copyright 2016 Todd Wackford
 *
 *  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 *  in compliance with the License. You may obtain a copy of the License at:
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
 *  on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
 *  for the specific language governing permissions and limitations under the License.
 *
 */
definition(
    name: "template",
    namespace: "twack",
    author: "Todd Wackford",
    description: "template for app.setttings",
    category: "Safety & Security",
    iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
    iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
    iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
    oauth: true) {
    appSetting "clientId"
    appSetting "clientSecret"
}


preferences {
	section("Title") {
		// TODO: put inputs here
	}
}

def installed() {
	log.debug "Installed with settings: ${settings}"

	initialize()
}

def updated() {
	log.debug "Updated with settings: ${settings}"

	unsubscribe()
	initialize()
}

def initialize() {
	// TODO: subscribe to attributes, devices, locations, etc.
    log.debug "Client Id is: ${clientId}"
    log.debug "Client Secret is: ${clientSecret}"
}

// TODO: implement event handlers

(Martin Verbeek) #3

Okay, thanks, will do. So the clientid and clientserver in OAuth section of
the IDE cannot be accessed in ghe app?

Op do 1 sep. 2016 20:34 schreef Todd Wackford <smartthings@discoursemail.com