Skip to content
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] Make OAuth2 token refresh RFC compliant #14568

Merged
merged 2 commits into from Mar 16, 2023

Conversation

clinique
Copy link
Contributor

@clinique clinique commented Mar 10, 2023

Cherry picking PR #14548 in branch 3.4.x

Fixes #14546

Signed-off-by: clinique <gael@lhopital.org>
@clinique clinique requested a review from lolodomo as a code owner March 10, 2023 16:18
@clinique clinique changed the title [Netatmo] Token refresh storage and update every 3 hours [Netatmo] Token refresh storage and update every 3 hours (3.4.x) Mar 10, 2023
@clinique clinique added enhancement An enhancement or new feature for an existing add-on additional testing preferred The change works for the pull request author. A test from someone else is preferred though. labels Mar 10, 2023
@jlaur
Copy link
Contributor

jlaur commented Mar 10, 2023

@clinique - with 3.4.2 and a JAR built from this branch, when I go to http://<your openHAB address>:8080/netatmo/connect/<_CLIENT_ID_> and click "Authorize Thing", I'm taken to a Netatmo page. When I here click "Yes, I accept", I get this result:

HTTP ERROR 500 java.lang.NoSuchMethodError: 'java.lang.String java.lang.String.formatted(java.lang.Object[])'
URI:	/netatmo/connect/<client_id>
STATUS:	500
MESSAGE:	java.lang.NoSuchMethodError: 'java.lang.String java.lang.String.formatted(java.lang.Object[])'
SERVLET:	org.ops4j.pax.web.service.spi.model.ServletModel-64
CAUSED BY:	java.lang.NoSuchMethodError: 'java.lang.String java.lang.String.formatted(java.lang.Object[])'
Caused by:
java.lang.NoSuchMethodError: 'java.lang.String java.lang.String.formatted(java.lang.Object[])'
	at org.openhab.binding.netatmo.internal.api.AuthenticationApi.requestToken(AuthenticationApi.java:99)
	at org.openhab.binding.netatmo.internal.api.AuthenticationApi.authorize(AuthenticationApi.java:74)
	at org.openhab.binding.netatmo.internal.handler.ApiBridgeHandler.openConnection(ApiBridgeHandler.java:167)
	at org.openhab.binding.netatmo.internal.servlet.GrantServlet.handleRedirect(GrantServlet.java:124)
	at org.openhab.binding.netatmo.internal.servlet.GrantServlet.doGet(GrantServlet.java:82)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:799)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:550)
	at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:74)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:600)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1624)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1440)
	at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:294)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:501)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1594)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1355)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
	at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:90)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
	at org.eclipse.jetty.server.Server.handle(Server.java:516)
	at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:487)
	at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:732)
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:479)
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:277)
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)
	at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:338)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:315)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:173)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:131)
	at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:409)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:883)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1034)
	at java.base/java.lang.Thread.run(Thread.java:829)

Do you know what might be the issue?

@jlaur
Copy link
Contributor

jlaur commented Mar 10, 2023

@clinique - oh, I just realized I compiled the JAR with Java 17. String.formatted was introduced in Java 15, so can't be used with 3.4.

@lolodomo
Copy link
Contributor

I believe @clinique introduced code that is not compatible with Java 11 (formatted).

Signed-off-by: clinique <gael@lhopital.org>
@jlaur jlaur added the patch A PR that has been cherry-picked to a patch release branch label Mar 11, 2023
@jlaur jlaur changed the title [Netatmo] Token refresh storage and update every 3 hours (3.4.x) [netatmo] Make OAuth2 token refresh RFC compliant Mar 11, 2023
Copy link
Contributor

@jlaur jlaur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@jlaur jlaur merged commit 3bab21f into openhab:3.4.x Mar 16, 2023
1 check passed
@jlaur jlaur removed the additional testing preferred The change works for the pull request author. A test from someone else is preferred though. label Mar 16, 2023
@jlaur
Copy link
Contributor

jlaur commented Mar 16, 2023

Regarding test, I've been running this version since the PR was created. We probably can't test more until Netatmo actually makes the changes.

@jlaur
Copy link
Contributor

jlaur commented Mar 16, 2023

@kaikreuzer - because of other (conflicting) Netatmo changes in the main branch, we backported this fix through this dedicated PR. I don't know how you create the release notes for patch releases, but this one should be mentioned. I don't know if milestone should be set to anything on this PR.

@kaikreuzer
Copy link
Member

Thanks @jlaur. I am actually pulling all issues with 4.0 milestone and "patch" label for the release notes. I've therefore just added the "patch" label to #14548 as well, so that we can see on that PR directly that it has been backported (in this case through a dedicated PR instead of being cherry-picked).

@kaikreuzer kaikreuzer added patch A PR that has been cherry-picked to a patch release branch and removed patch A PR that has been cherry-picked to a patch release branch labels Mar 16, 2023
@clinique clinique deleted the netatmo_oauth_14546_34X branch March 17, 2023 08:03
@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/new-netatmo-binding-starting-oh-3-3-m5/135777/216

@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/new-netatmo-binding-starting-oh-3-3-m5/135777/238

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature for an existing add-on patch A PR that has been cherry-picked to a patch release branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants