J'ai changé de méthode en consultant la doc ici:
https://developer-v4.enphase.com/docs/quickstart.html
J'ai créer mon compte et donner les autorisations pour surveiller l'installation.
J'essaye de coder maintenant le script pour récupérer le TOKEN, la difficulté est la syntaxe du header d'autorisation:
Code : Tout sélectionner
return {
on = {
timer = {
'every 1 minutes' -- just an example to trigger the request
},
httpResponses = {
'trigger' -- must match with the callback passed to the openURL command
}
},
logging = {
level = domoticz.LOG_INFO,
marker = 'template',
},
execute = function(domoticz, item)
if (item.isTimer) then
domoticz.openURL({
url = 'https://api.enphaseenergy.com/oauth/token?grant_type=authorization_code&redirect_uri=https://api.enphaseenergy.com/oauth/redirect_uri&code=xxxxxx',
headers = { ['Authorization:'] ='Basic xxxxxx'},
method = 'POST',
callback = 'trigger', -- see httpResponses above.
})
end
if (item.isHTTPResponse) then
if (item.ok) then
if (item.isJSON) then
local jeton = json.access_token -- just an example
end
else
domoticz.log('There was a problem handling the request', domoticz.LOG_ERROR)
domoticz.log(item, domoticz.LOG_ERROR)
end
end
end
}
La doc de DZ vent mentione un truc comme ça
Code : Tout sélectionner
domotique . openURL ({
url = 'https://somedomain.com/service/getInfo' ,
headers = { [ 'x-access-token' ] = '<api-key>' },
method = 'GET' ,
callback = ' infos'
})
et ce site
https://developer.mozilla.org/en-US/doc ... horization
précise cette syntaxe :
Authorization: Basic <credentials>
Le log me renvoie des erreurs 401, accès interdit
Quelle est la bonne syntaxe pour le headers? J'ai essayer plein de variante avec ou sans <>
Merci