JohnvandeVrugt / toonapilib4domoticz

A simple toonapilib based python plugin for domoticz
MIT License
7 stars 6 forks source link

Toon new API authentication #25

Closed stephanvdplas closed 4 years ago

stephanvdplas commented 4 years ago

Toon will use new authentication starting 12/1/2019. See https://developer.toon.eu/authentication for more info.

From December 2019 onwards, Eneco users are required to use the “mijn Eneco” login to access their Toon, use the following call from the application to use the “mijn Eneco” as identity source:

curl -v -k https://api.toon.eu/authorize?response_type=code &redirect_uri= &client_id= &issuer=identity.toon.eu &tenant_id=eneco From the ToonAPI website's login page, the end user needs to provide his credentials. A redirect will then be performed to the redirect_uri provided before with a code. The application can now use that code and the application key pair to get an access token that looks like this:

curl -k -X POST -H "Content-Type: application/x-www-form-urlencoded" -d "client_id= &client_secret= &grant_type=authorization_code &redirect_uri= &tenant_id=eneco &code=" https://api.toon.eu/token

Again, in this call, when users have logged in via "Mijn Eneco", add the issuer to this request:

curl -k -X POST -H "Content-Type: application/x-www-form-urlencoded" -d "client_id= &client_secret= &grant_type=authorization_code &issuer=identity.toon.eu &redirect_uri= &tenant_id=eneco &code=" https://api.toon.eu/token

stephanvdplas commented 4 years ago

Is the ToonAPIlib4Domoticz compatible with this new authentication method?

stephanvdplas commented 4 years ago

A 10-year-valid access token can now be generated via "https://api.toon.eu/toonapi-accesstoken?tenant_id=eneco&client_id=". I think this key has to be entered somewhere in the ToonApi to connect to the Eneco site.

tne7laa commented 4 years ago

I have followed the instruction in my email and managed to get an "Access token" as stated. But I don't have a clue what to do with it. Hope someone does understand what they want us to do and explain here for us.

rene2716 commented 4 years ago

Any news on this?

darkrain-nl commented 4 years ago

Version 4 of the library from Costas now has support for this, but that don't work with this plugin for now. Let me check what I can do to make it work. @JohnvandeVrugt perhaps this is to complicated for my Python skills but I'll try anyway ;)

rene2716 commented 4 years ago

Keep up the good work guys, hate to see it stop working :)

Op za 30 nov. 2019 15:26 schreef Jan Donker notifications@github.com:

Version 4 of the library from Costas now has support for this, but that don't work with this plugin for now. Let me check what I can do to make it work. @JohnvandeVrugt https://github.com/JohnvandeVrugt perhaps this is to complicated for my Python skills but I'll try anyway ;)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/JohnvandeVrugt/toonapilib4domoticz/issues/25?email_source=notifications&email_token=AJWNAS4EDYMJR5QMVS3RCNDQWJZZBA5CNFSM4JQM7Y22YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFQIRFY#issuecomment-559974551, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJWNAS5XUFQU4H6VLCX5PP3QWJZZBANCNFSM4JQM7Y2Q .

darkrain-nl commented 4 years ago

I already have it working with the new V4 library, will do a PR soon

rene2716 commented 4 years ago

Great

Op za 30 nov. 2019 15:55 schreef Jan Donker notifications@github.com:

I already have it working with the new V4 library, will do a PR soon

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/JohnvandeVrugt/toonapilib4domoticz/issues/25?email_source=notifications&email_token=AJWNAS6DPV6XSALOEIQ6DZLQWJ5HDA5CNFSM4JQM7Y22YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFQJPXQ#issuecomment-559978462, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJWNAS77YRUGV3HI2IJOQOTQWJ5HDANCNFSM4JQM7Y2Q .

darkrain-nl commented 4 years ago

https://github.com/JohnvandeVrugt/toonapilib4domoticz/pull/26 makes this work.

The changes are not really hard to do, just run "sudo pip3 install toonapilib -U" and edit "plugin.py" with what I did in the PR.

tne7laa commented 4 years ago

Great work!. Does anyone also use the homebridge plugin? I'm using it for controlling Toon via Apple HomeKit and needs also changes I think.

rene2716 commented 4 years ago

Hi,

Did the adjustments but now its showing below and i do not see device updates 2019-11-30 17:37:45.534 Error: (toon) 'onStart' failed 'AttributeError':''NoneType' object has no attribute 'smartplugs''. 2019-11-30 17:37:45.534 Error: (toon) ----> Line 112 in '/home/pi/domoticz/plugins/toonapilib4domoticz/plugin.py', function onStart 2019-11-30 17:37:45.534 Error: (toon) ----> Line 66 in '/home/pi/domoticz/plugins/toonapilib4domoticz/plugin.py', function on_start 2019-11-30 17:37:45.534 Error: (toon) ----> Line 40 in '/home/pi/domoticz/plugins/toonapilib4domoticz/devices/device_factory.py', function create_devices

Op za 30 nov. 2019 om 16:20 schreef Jan Donker notifications@github.com:

26 https://github.com/JohnvandeVrugt/toonapilib4domoticz/pull/26 makes

this work.

The changes are not really hard to do, just run "sudo pip3 install toonapilib -U" and edit "plugin.py" with what I did in the PR.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/JohnvandeVrugt/toonapilib4domoticz/issues/25?email_source=notifications&email_token=AJWNASY7SVKXSQQSYB62IVTQWKACNA5CNFSM4JQM7Y22YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFQKKUQ#issuecomment-559981906, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJWNAS4OTWMVFXCGUEN3CXDQWKACNANCNFSM4JQM7Y2Q .

darkrain-nl commented 4 years ago

Then you did not provide an Access Token, sorry I did not tell you to create this first. Please go to "https://api.toon.eu/toonapi-accesstoken?tenant_id=eneco&client_id=" where the consumer key is the value you can find on https://developer.toon.eu or more specific https://developer.toon.eu/user/me/apps

Sorry for not being complete..

rene2716 commented 4 years ago

Ha, i did but with the wrong consumer key (i have more) and then some python indent errors to fix (rather strict with last python versions not used to that :)

all fine now, great job

Op za 30 nov. 2019 om 17:48 schreef Jan Donker notifications@github.com:

Then you did not provide an Access Token, sorry I did not tell you to create this first. Please go to " https://api.toon.eu/toonapi-accesstoken?tenant_id=eneco&client_id=" where the consumer key is the value you can find on https://developer.toon.eu or more specific https://developer.toon.eu/user/me/apps

Sorry for not being complete..

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/JohnvandeVrugt/toonapilib4domoticz/issues/25?email_source=notifications&email_token=AJWNAS5723R4YS5YLYRNAETQWKKMNA5CNFSM4JQM7Y22YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFQNKWA#issuecomment-559994200, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJWNAS7AP6ESLE4VDXJUYHTQWKKMNANCNFSM4JQM7Y2Q .

JohnvandeVrugt commented 4 years ago

Thanks Jan, for doing a good job. I didn't had the time to check out the new API / toonapilib requirements.