Error 403 with Ecowatt add-on (new API version)

Hi

I followed the documentation at this link: Ecowatt - Bindings | openHAB

I have created my account to have access to the Ecowatt API. I got my client ID and my secret ID.
I created the Ecowatt binding but it goes into COMMUNICATION_ERROR with the message:
[WARN ] [watt.internal.handler.EcowattHandler] - REST API request failed: statusCode=403, message=

Is the add-on still functional? Do I have to wait a period after creating the account (at the time of writing this message, it has been 2 hours)?

Thanks,
Matthias

Yes, the binding still works well.

Try enabling TRACE logs for the binding to get possible more information.

I see lot of messages. But I have got some messages like

2023-11-17 21:55:46.430 [DEBUG] [org.eclipse.jetty.server.Server ] - REQUEST GET /rest/things/ecowatt:signals:f9b6efb960 on HttpChannelOverHttp@3daf40d{s=HttpChannelState@101b0dff{s=HANDLING rs=BLOCKING os=OPEN is=IDLE awp=false se=false i=
true al=0},r=2,c=false/false,a=HANDLING,uri=//192.168.1.14:8080/rest/things/ecowatt:signals:f9b6efb960,age=6}
2023-11-17 21:55:46.431 [DEBUG] [etty.server.handler.gzip.GzipHandler] - GzipHandler@3c0d9d15{STARTED,min=1024,inflate=-1} handle Request(GET //192.168.1.14:8080/rest/things/ecowatt:signals:f9b6efb960)@17a62c6e in null
2023-11-17 21:55:46.432 [DEBUG] [.jetty.server.handler.ContextHandler] - scope null||/rest/things/ecowatt:signals:f9b6efb960 @ o.o.p.w.s.j.i.PaxWebServletContextHandler@334d2fcd{/rest,null,AVAILABLE}
2023-11-17 21:55:46.433 [DEBUG] [.jetty.server.handler.ContextHandler] - context=/rest||/things/ecowatt:signals:f9b6efb960 @ o.o.p.w.s.j.i.PaxWebServletContextHandler@334d2fcd{/rest,null,AVAILABLE}
2023-11-17 21:55:46.436 [DEBUG] [eclipse.jetty.servlet.ServletHandler] - servlet /rest||/things/ecowatt:signals:f9b6efb960 → cxf-servlet==javax.servlet.Servlet@e2fb1709{jsp=null,order=-1,inst=true,async=true,src=EMBEDDED:null,STARTED}
2023-11-17 21:55:46.442 [DEBUG] [rg.apache.cxf.jaxrs.utils.JAXRSUtils] - Trying to select a resource class, request path : /things/ecowatt:signals:f9b6efb960
2023-11-17 21:55:46.443 [DEBUG] [rg.apache.cxf.jaxrs.utils.JAXRSUtils] - No resource class match for org.openhab.core.id.internal.UUIDResource, request path : /things/ecowatt:signals:f9b6efb960
2023-11-17 21:55:46.445 [DEBUG] [rg.apache.cxf.jaxrs.utils.JAXRSUtils] - No resource class match for org.openhab.core.automation.rest.internal.ThingActionsResource, request path : /things/ecowatt:signals:f9b6efb960
2023-11-17 21:55:46.447 [DEBUG] [rg.apache.cxf.jaxrs.utils.JAXRSUtils] - No resource class match for org.openhab.core.automation.rest.internal.TemplateResource, request path : /things/ecowatt:signals:f9b6efb960
2023-11-17 21:55:46.448 [DEBUG] [rg.apache.cxf.jaxrs.utils.JAXRSUtils] - No resource class match for org.openhab.core.io.rest.internal.resources.SystemInfoResource, request path : /things/ecowatt:signals:f9b6efb960
2023-11-17 21:55:46.450 [DEBUG] [rg.apache.cxf.jaxrs.utils.JAXRSUtils] - Resource class org.openhab.core.io.rest.internal.resources.RootResource may get selected, request path : org.openhab.core.io.rest.internal.resources.RootResource, resource
class @Path : /things/ecowatt:signals:f9b6efb960
2023-11-17 21:55:46.451 [DEBUG] [rg.apache.cxf.jaxrs.utils.JAXRSUtils] - No resource class match for org.openhab.core.automation.rest.internal.ModuleTypeResource, request path : /things/ecowatt:signals:f9b6efb960
2023-11-17 21:55:46.452 [DEBUG] [rg.apache.cxf.jaxrs.utils.JAXRSUtils] - No resource class match for org.openhab.core.io.rest.audio.internal.AudioResource, request path : /things/ecowatt:signals:f9b6efb960
2023-11-17 21:55:46.454 [DEBUG] [rg.apache.cxf.jaxrs.utils.JAXRSUtils] - No resource class match for org.openhab.core.io.rest.auth.internal.TokenResource, request path : /things/ecowatt:signals:f9b6efb960
2023-11-17 21:55:46.455 [DEBUG] [rg.apache.cxf.jaxrs.utils.JAXRSUtils] - No resource class match for org.openhab.core.io.rest.core.internal.addons.AddonResource, request path : /things/ecowatt:signals:f9b6efb960
2023-11-17 21:55:46.456 [DEBUG] [rg.apache.cxf.jaxrs.utils.JAXRSUtils] - No resource class match for org.openhab.core.io.rest.core.internal.config.ConfigDescriptionResource, request path : /things/ecowatt:signals:f9b6efb960
2023-11-17 21:55:46.458 [DEBUG] [rg.apache.cxf.jaxrs.utils.JAXRSUtils] - No resource class match for org.openhab.core.io.rest.core.internal.discovery.DiscoveryResource, request path : /things/ecowatt:signals:f9b6efb960
2023-11-17 21:55:46.459 [DEBUG] [rg.apache.cxf.jaxrs.utils.JAXRSUtils] - No resource class match for org.openhab.core.io.rest.core.internal.service.ConfigurableServiceResource, request path : /things/ecowatt:signals:f9b6efb960
2023-11-17 21:55:46.460 [DEBUG] [rg.apache.cxf.jaxrs.utils.JAXRSUtils] - No resource class match for org.openhab.core.io.rest.sse.SseResource, request path : /things/ecowatt:signals:f9b6efb960
2023-11-17 21:55:46.461 [DEBUG] [rg.apache.cxf.jaxrs.utils.JAXRSUtils] - No resource class match for org.openhab.core.io.rest.swagger.impl.OpenApiResource, request path : /things/ecowatt:signals:f9b6efb960
2023-11-17 21:55:46.463 [DEBUG] [rg.apache.cxf.jaxrs.utils.JAXRSUtils] - No resource class match for org.openhab.core.karaf.internal.LoggerResource, request path : /things/ecowatt:signals:f9b6efb960
2023-11-17 21:55:46.464 [DEBUG] [rg.apache.cxf.jaxrs.utils.JAXRSUtils] - No resource class match for org.openhab.core.automation.rest.internal.RuleResource, request path : /things/ecowatt:signals:f9b6efb960
2023-11-17 21:55:46.466 [DEBUG] [rg.apache.cxf.jaxrs.utils.JAXRSUtils] - No resource class match for org.openhab.core.io.rest.core.internal.persistence.PersistenceResource, request path : /things/ecowatt:signals:f9b6efb960
2023-11-17 21:55:46.467 [DEBUG] [rg.apache.cxf.jaxrs.utils.JAXRSUtils] - No resource class match for org.openhab.core.io.rest.core.internal.item.ItemResource, request path : /things/ecowatt:signals:f9b6efb960
2023-11-17 21:55:46.468 [DEBUG] [rg.apache.cxf.jaxrs.utils.JAXRSUtils] - No resource class match for org.openhab.core.io.rest.core.internal.tag.TagResource, request path : /things/ecowatt:signals:f9b6efb960
2023-11-17 21:55:46.470 [DEBUG] [rg.apache.cxf.jaxrs.utils.JAXRSUtils] - No resource class match for org.openhab.core.io.rest.core.internal.channel.ChannelTypeResource, request path : /things/ecowatt:signals:f9b6efb960
2023-11-17 21:55:46.471 [DEBUG] [rg.apache.cxf.jaxrs.utils.JAXRSUtils] - No resource class match for org.openhab.core.io.rest.core.internal.link.ItemChannelLinkResource, request path : /things/ecowatt:signals:f9b6efb960
2023-11-17 21:55:46.473 [DEBUG] [rg.apache.cxf.jaxrs.utils.JAXRSUtils] - No resource class match for org.openhab.core.io.rest.core.internal.profile.ProfileTypeResource, request path : /things/ecowatt:signals:f9b6efb960
2023-11-17 21:55:46.474 [DEBUG] [rg.apache.cxf.jaxrs.utils.JAXRSUtils] - No resource class match for org.openhab.core.io.rest.core.internal.discovery.InboxResource, request path : /things/ecowatt:signals:f9b6efb960
2023-11-17 21:55:46.475 [DEBUG] [rg.apache.cxf.jaxrs.utils.JAXRSUtils] - No resource class match for org.openhab.core.io.rest.core.internal.thing.ThingTypeResource, request path : /things/ecowatt:signals:f9b6efb960
2023-11-17 21:55:46.477 [DEBUG] [rg.apache.cxf.jaxrs.utils.JAXRSUtils] - Resource class org.openhab.core.io.rest.core.internal.thing.ThingResource may get selected, request path : org.openhab.core.io.rest.core.internal.thing.ThingResource, reso
urce class @Path : /things/ecowatt:signals:f9b6efb960

Is it possible to have an example of API request to test my ID (client and secret) ?

They are not ecowatt binding logs.

log:set TRACE org.openhab.binding.ecowatt

On what platform is running your OH server? RPI? Docker?..

I try to reboot mon OH server without success.

My OH server (4.0.4) works on Armbian without docker and not on Rpi

2023-11-18 10:39:43.471 [DEBUG] [watt.internal.handler.EcowattHandler] - scheduleNextUpdate delay=0s retryIfLimitReached=true
2023-11-18 10:39:43.475 [DEBUG] [watt.internal.handler.EcowattHandler] - updateChannel channelId=null, retryIfApiLimitReached=true
2023-11-18 10:39:43.476 [DEBUG] [watt.internal.restapi.EcowattRestApi] - API request signals
2023-11-18 10:39:43.479 [DEBUG] [watt.internal.restapi.EcowattRestApi] - Token kJ2pAYDH2ku1g8OVq6pxrpPoeZA5H2pSgo2TyTcYzE0K593hCbxLXI of type Bearer created on 2023-11-18T09:00:02.927550906Z expiring after 7200 seconds
2023-11-18 10:39:43.584 [TRACE] [watt.internal.restapi.EcowattRestApi] - API response statusCode=403 content=
2023-11-18 10:39:43.587 [WARN ] [watt.internal.handler.EcowattHandler] - REST API request failed: statusCode=403, message=
2023-11-18 10:39:43.593 [DEBUG] [watt.internal.handler.EcowattHandler] - now 2023-11-18T10:39:43.590832387+01:00[Europe/Paris]
2023-11-18 10:39:43.596 [DEBUG] [watt.internal.handler.EcowattHandler] - scheduleNextUpdate delay=1219s retryIfLimitReached=true

They are the logs I requested.
So the OAuth2 token is retrieved. That means your setup is very probably correct.
Then the URL is called (with the token) but status 403 is returned. I have really no idea why !

The binding is using that URL with the retrieved OAuth2 token: https://digital.iservices.rte-france.com/open_api/ecowatt/v4/signals

I downloaded the API guide and since 07/11/2023, it has been upgraded to v5

The new URL is : https://digital.iservices.rte-france.com/open_api/ecowatt/v5/signals

Maybe there is a problem with my token that can only work on v5?

You created your application and get your client id/secret very recently (after the 7th of November ?

By the way, I will have a look to update the binding to use API v5.

Hi,

Yes I have created my account after the 7th november

Here is the description of code 403 in the API: Erreur gĂ©nĂ©rĂ©e si l’appelant n’est pas habilitĂ© Ă  appeler la ressource
My hypothesis is that your account is not allowed to use V4 API.

I am going to move the binding to V5 API during the weekend.

V5 introduced a new value:

0 : Vert + production décarbonée

1 : Vert

2 : Orange

3 : Rouge

Ok, I updated the binding to API v5 and now this is my time to get a 403 error.

I think I know the reason. In fact, when registering, you register to a version of the API. For me, it looks like that and you can see the version at the bottom:

In the portal, the version is now V5.0:
image

I already guess that you have registered to the “V5.0”.

So in my case, I will have to register to the new version and get new id/secret.

Thank you for your research.

When you have implemented the new version, how is it possible to update on my Openhab server? It’s something I’ve never done.

With my special version for API v5.0, I now get error 401. I hope it is because my token was created before app v5.0 was created. I will see if it works after my token is expired.

All this will make transition for users using v4.0 very difficult. I will have probably to add a parameter to select the API version, with default being v4 with a clear mention that it is deprecated. Then I will have to describe in documentation how to switch from one API version to another and this is not as easy as we could expect.

I also disabled my v4.0 application in the RTE portal, I am not sure if this is required or not.

Let see first if I am able to make the binding working again with the new API v5. It should already work but now I get error 401.

1 Like

Just for your information, it is now working with API v5.
Tomorrow, I will add the configuration setting to select the API version.

1 Like

The change to support API v5 is submitted.

@Matt_Jam : to test it, first you will certainly need to run OH 4.1. Then uninstall the ecowatt binding. Then download the zip I provided in Github, rename it into .jar and move it in your “addons” folder. Finally, open your thing configuration and select 5 as API version. After that, it should work for you too.

On my side, I am currently testing the switch between API versions (in the RTE portal, I have one app for the API v4 and one app for the API v5) and it seems to work. It is not working immediately when switching, I believe we need to wait for the token renewal. Edit: tests OK

My OH 4.1 is on docker. I’m not sure I can change the .jar