-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[netatmo] Switch to Code Granting process #12726
Conversation
Signed-off-by: clinique <[email protected]>
Current status : authentication flow works. Breaking changes :
|
@clinique : why saving technical data in thing configuration? The user will not be able to set them as they are provided by the API. |
If you do not save them, then you've got to redo the approval process - not doable. |
Can you link to some documentation describing the authorization flow/API? I would like to understand this. Is this the new approach: https://dev.netatmo.com/apidocumentation/oauth? |
And did you think about using OAuth2 provided by a package of the core framework? |
Keeping the refresh token is enough. |
It was my original plan but I had an issue with the answer provided by the API (see here). So we arrived here and there . But it still does not work. IIRW the core oauth is not able to reach the deserializer I provide. |
Maybe we can debug what would be wrong in core? |
I believe that the core bundle must be able to create imports dynamically. This can be achieved by adding |
unfortunately not, It was 2 years ago... |
We must keep in mind that it should be merged before 3.3 is released (end of June) to avoid a second breaking change for users and to have a working 3.3 binding in September when Netatmo will stop the old authentication method. @clinique :please submit your last code if ready |
Not much time available this week, I'll do my best as soon as possible - or else, I leave the webhooks untouched, just to take care of code granting, without optimizing servlets. |
Signed-off-by: clinique <[email protected]>
Signed-off-by: clinique <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review part 1 of 2
...ng.netatmo/src/main/java/org/openhab/binding/netatmo/internal/config/ConfigurationLevel.java
Outdated
Show resolved
Hide resolved
@@ -330,8 +330,7 @@ thing-type.netatmo.wind.description = Wind sensor reporting wind angle and stren | |||
|
|||
conf-error-no-client-id = Cannot connect to Netatmo bridge as no client id is available in the configuration | |||
conf-error-no-client-secret = Cannot connect to Netatmo bridge as no client secret is available in the configuration | |||
conf-error-no-username = Cannot connect to Netatmo bridge as no username is available in the configuration | |||
conf-error-no-password = Cannot connect to Netatmo bridge as no password is available in the configuration | |||
conf-error-grant-needed = Configuration incomplete, please grant the binding to Netatmo Connect. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please run the i18n tool as there should be other changes (parameter refreshToken, username, password).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did it - that's weird.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I think I understand, this is not something new in this PR but something we missed when reviewing your PR for the new binding.
As you have no static things declared (in XML) linked to these configs, the i18n tool does produce nothing.
So you have no label/description for these configurations available in the translation file.
The solution would be to use @text
in the config.xml file and add the corresponding entries in the default translation properties file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be fixed in a next PR if we want to merge the current PR very soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...or by extending the translation tool to take this case in account ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tool can do nothing as it will know what key to produce. That is typically the case where you need to use @text/myparameterlabel
and in this case, the tool will add the entry myparameterlabel
in the properties file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am going to create a PR for that.
Signed-off-by: clinique <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget to update the things/netatmo.things
example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review part 2 o f2
...ing.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/ApiBridgeHandler.java
Outdated
Show resolved
Hide resolved
...ng.netatmo/src/main/java/org/openhab/binding/netatmo/internal/config/ConfigurationLevel.java
Outdated
Show resolved
Hide resolved
...nding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/servlet/WebhookServlet.java
Show resolved
Hide resolved
...nding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/servlet/WebhookServlet.java
Outdated
Show resolved
Hide resolved
...nding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/servlet/WebhookServlet.java
Outdated
Show resolved
Hide resolved
As soon as you push an update with the resolved comments, I will test it. |
Signed-off-by: clinique <[email protected]>
@clinique, I built you latest code and was able to get it up and running. The only problem I ran into is the refresh token isn't optional for file based configurations. |
Signed-off-by: clinique <[email protected]>
Same for me, it is working. Will see tomorrow if renewing is working. |
Can we elaborate how much it will be a breaking change for users that already moved to the new binding ? |
For users using UI, deleting and recreating the Account thing should be enough. |
This can be done without removing all child things ? |
@clinique: please answer to the last 2 open comments and then I will commit. |
Signed-off-by: clinique <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you
The breaking change is already mentioned in 3.3 so there is nothing more to add for users that will upgrade from 3.2 to 3.3 in July. For users upgrading from 3.3M5 to next 3.3M6 at end of month, the account thing will certainly be offline. I think we should mention in the forum topic that the account bridge thing has to be removed and created again, child things have to be attached again to the new bridge. |
@clinique - thank you! Authorization process went smooth (file-based configuration). |
This pull request has been mentioned on openHAB Community. There might be relevant details there: https://community.openhab.org/t/netatmo-recreate-things/136451/2 |
Signed-off-by: clinique <[email protected]>
Signed-off-by: clinique <[email protected]> Signed-off-by: Andras Uhrin <[email protected]>
Signed-off-by: clinique <[email protected]>
Based on the work done in the spotify binding.
This exposes a second servlet, so I refactor servlet handling in the binding.
Closing issue #12677
Signed-off-by: clinique [email protected]