12.07.2021, 15:07
Try this, change data inside encodepost table as needed:
Code:
require('socket.http')
function encodepost(t)
local res = {}
local esc = require('socket.url').escape
for k, v in pairs(t) do
res[ #res + 1 ] = esc(k) .. '=' .. esc(v)
end
return table.concat(res, '&')
end
url = 'https://oauth.hanet.com/token'
payload = encodepost({
code = 'CODE',
grant_type = 'authorization_code',
client_id = 'CLIENT_ID',
redirect_uri = 'HTTP_CALLBACK_URL',
client_secret = 'CLIENT_SECRET',
})
res, err, headers, status = socket.http.request(url, payload)
log(res, err, headers, status)