So with further experimentation I have gotten this far:
local socket = require("socket")
local http = require("ssl.https")
local ltn12 = require("ltn12")
http.TIMEOUT = 5
local resultTable = {}
local result, respcode, respheaders, respstatus = http.request {
url = "https://api.particle.io/oauth/token",
sink = ltn12.sink.table(resultTable),
method = "POST",
user = "MyClientID",
password = "My Something Secret",
headers = {
grant_type = "password",
username = "MyUsername",
password = "MyPassord",
},
}
print(result)
print(respcode)
print(respstatus)
for s,i in pairs(resultTable) do
print(s,i)
end
and the Result is:
1
400
HTTP/1.1 400 Bad Request
1 {"error":"invalid_request","error_description":"Method must be POST with application/x-www-form-urlencoded encoding"}
Now I have Read up on this and it says a 400 Request means : Your request is not understood by the device, or the requested subresource (variable/function) has not been exposed.