403 on device subscription

Thank you for both responses. At this point, I am not using the SDK because of platform limitations and just reversed engineered it. Here is a working example for others that come across the same concern.


def refreshToken() {
    logDebug "${app.getLabel()} executing 'refreshToken()'"
    
    def refreshToken = state.refreshToken // captured from INSTALL or UPDATE lifecycle first time. Good for 24hrs.
    def clientId = state.clientId // user input from SmartThings Developer SmartApp configuration
    def clientSecret = state.clientSecret // user input from SmartThings Developer SmartApp configuration   
  
    def params = [
        //uri: "https://api.smartthings.com/oauth/token",
        uri: "https://auth-global.api.smartthings.com/oauth/token", 
        query: [ grant_type:"refresh_token", client_id:"${clientId}", refresh_token:"${refreshToken}" ],
        contentType: "application/x-www-form-urlencoded",
        requestContentType: "application/json",
		headers: [ Authorization: "Basic ${("${clientId}:${clientSecret}").bytes.encodeBase64().toString()}" ]
    ] 
    
    try {
        httpPost(params) { resp ->
            //resp.headers.each { logTrace "${it.name} : ${it.value}" }
            //logTrace "response contentType: ${resp.contentType}"
            logTrace "response data: ${resp.data}"            
            // strange json'y response. this works good enough to solve. 
            def respStr = resp.data.toString()
            respStr = respStr.replace("[{","{")
            respStr = respStr.replace("}:null]","}")    
            def respJson = new JsonSlurper().parseText(respStr)
            logTrace "response json: ${respJson}"
            
            state.authToken = respJson.access_token 
            state.refreshToken = respJson.refresh_token            
         }
    } catch (e) {
        logWarn "${app.getLabel()} refreshToken error: $e"
    }
}