After looking at other plug-ins I found that I have put all my code in onHeartbeat, other plug-in are using onConnect, onMessage etc.
So I tried to rewrite my code but I didn’t get so far before I got a problem.
I am trying to get a token using an API.
I can get the token using requests.request in a separate python script.
The data(payload) to be sent with Connection.Send() must be as unicode string, byte or byte array.
I have low knowledge about creating a plug-in.
Code: Select all
payload = {
'grant_type':'refresh_token',
'client_id':'319d92371dhdhd3d3782',
'client_secret': 'QoSJ/k9Ky/ddX4RX45V7Ohdud2L53=',
'refresh_token': '4AM5!_eBNb9yxjUuwQdNeN0EQEaBt6LA49o4fxB6Tw'
}
headers = { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8', 'Host': 'api.nibeuplink.com' }
Connection.Send({'Verb': 'POST', 'URL':'/oauth/token', 'Headers': headers, 'Data': payload})
Scope is not required