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

[oauth] scope in AccessTokenResponse #1888

Closed
clinique opened this issue Dec 4, 2020 · 6 comments · Fixed by #3537
Closed

[oauth] scope in AccessTokenResponse #1888

clinique opened this issue Dec 4, 2020 · 6 comments · Fixed by #3537
Labels
enhancement An enhancement or new feature of the Core

Comments

@clinique
Copy link
Contributor

clinique commented Dec 4, 2020

Hello,
I'm reviewing the netatmo binding and would like to remove all external dependencies. Thus, using OAuthFactory.
This works nearly well, except that Netatmo API response is formed this way :

{
"access_token":"5xxxxx95e984",
"refresh_token":"51cyyyyy841a489a4a346eb3b",
"scope":["read_station"],
"expires_in":10800,
"expire_in":10800
}

While in the API documentation, the scope should not be part of the answer, even worth, its a string array instead of the expected string.
So OAuthConnector fails to deserialize the AccessTokenResponse.

While on one hand, I can ask Netatmo (that I did) to respect better the RFC, I'm quite realistic regarding my chance to succeed.
Does anybody have an idea on how I could make this foot fit in the shoe ?

@clinique
Copy link
Contributor Author

clinique commented Dec 5, 2020

@cweitkamp : any indea ?

clinique added a commit to clinique/openhab-core that referenced this issue Dec 5, 2020
@cweitkamp cweitkamp added enhancement An enhancement or new feature of the Core PR pending labels Dec 23, 2020
@clinique
Copy link
Contributor Author

@cweitkamp : hello, just trying to integrate the merged PR in my binding, I get this error :

18:48:26.758 [main] ERROR o.o.c.a.o.internal.OAuthConnector:80 - Unable to construct custom deserializer 'org.openhab.binding.netatmo.NetatmoAccessTokenDeserializer'
java.lang.ClassNotFoundException: org.openhab.binding.netatmo.NetatmoAccessTokenDeserializer cannot be found by org.openhab.core.auth.oauth2client_3.1.0.202012270303
	at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:511)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:414)
	at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:153)

I suppose I've got a visibility issue from my class toward the core but can't figure how to solve it. Would you have an idea ?

@cweitkamp
Copy link
Contributor

Where did you put the new class? Into an internal package? Or do you expose it?

@clinique
Copy link
Contributor Author

clinique commented Dec 27, 2020

No, it's not an internal package, it's org.openhab.binding.netatmo
I suspect I may need to export it through the pom of the binding, searching appropriate syntax.
I tried adding

 <properties>
    <bnd.exportpackage>org.openhab.binding.netatmo.NAOAuthDeserializer</bnd.exportpackage>
  </properties>

with or without class name unsuccessfully as of now.

@clinique
Copy link
Contributor Author

clinique commented Dec 28, 2020

@cweitkamp : I'm wondering wether I should not be using Bundle.loadClass() instead of Class.forName() (cf here

@cweitkamp
Copy link
Contributor

tbh I am not sure. We maybe need a different classloader here. Just trying to figure out if we have a similar part of code somewhere else in OHC.

jlaur added a commit to jlaur/openhab-core that referenced this issue Apr 10, 2023
J-N-K pushed a commit that referenced this issue Apr 14, 2023
…#3537)

* Add possibility to inject custom GsonBuilder

Reverts #1891

Fixes #1888

Signed-off-by: Jacob Laursen <[email protected]>
splatch pushed a commit to ConnectorIO/copybara-hab-core that referenced this issue Jul 11, 2023
* Added capability for custom deserializer

Closes openhab#1888

Signed-off-by: clinique <[email protected]>
GitOrigin-RevId: f7e0339
splatch pushed a commit to ConnectorIO/copybara-hab-core that referenced this issue Jul 12, 2023
…openhab#3537)

* Add possibility to inject custom GsonBuilder

Reverts openhab#1891

Fixes openhab#1888

Signed-off-by: Jacob Laursen <[email protected]>
GitOrigin-RevId: eb6b6b9
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 of the Core
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants