Shame....
Here's a cut down example of some authentication I do in one of my drivers... There's a couple of references to variables and methods I haven't included, but hopefully it will make sense, if you can use it at all...
def retrieveAuthCode_KumoCloud() {
def vnewAuthCode = ""
def vbodyJson = "{ \"username\": \"${UserName}\", \"password\": \"${Password}\", \"AppVersion\": \"2.2.0\" }"
def postParams = [
uri: "${getBaseURL()}/login",
headers: getStandardHTTPHeaders_KumoCloud("yes"),
contentType: "application/json; charset=UTF-8",
body : vbodyJson
]
try {
httpPost(postParams)
{ resp ->
debugLog("${resp?.data}")
vnewAuthCode = "${resp?.data[0].token}";
debugLog("retrieveAuthCode_KumoCloud: New Auth Code - ${vnewAuthCode}");
}
}
catch (Exception e) {
errorLog("retrieveAuthCode_KumoCloud: Unable to query Mitsubishi Electric ${MELPlatform}: ${e}")
}
return vnewAuthCode
}
def getStandardHTTPHeaders_KumoCloud(excludeAuthCode) {
def headers = [:]
headers.put("Accept-Encoding", "gzip, deflate, br")
headers.put("Connection", "keep-alive")
headers.put("Accept", "application/json, text/plain, */*")
headers.put("DNT", "1")
headers.put("User-Agent", "")
headers.put("Content-Type", "application/json;charset=UTF-8")
headers.put("Origin", "https://app.kumocloud.com")
headers.put("Sec-Fetch-Site", "same-site")
headers.put("Sec-Fetch-Mode", "cors")
headers.put("Sec-Fetch-Dest", "empty")
headers.put("Referer", "https://app.kumocloud.com")
headers.put("Accept-Language", "en-US,en;q=0.9")
return headers
}