Nest binding 403 Forbidden?

Hi all,

I have a problem getting the nest binding up and running and haven’t found someone reporting the same error.
Have OH2 running but reverted to OH1 (1.8.2) without any other binding to exclude as many variables as possible.

Binding seems to fail getting the access token. From the logfile:

2016-04-16 21:49:42.277 TRACE o.o.b.n.internal.NestBinding[:155]- Querying Nest API
2016-04-16 21:49:42.277 TRACE o.o.b.n.internal.NestBinding[:613]- Retrieving access token in order to access the Nest API.
2016-04-16 21:49:42.285 TRACE o.o.b.n.internal.NestBinding[:616]- Request: AccessTokenRequest[pinCode=R2QAP792,clientId=:e3d582f6-4fd1-43fb-8fa4-6500bf2ca28a,clientSecret=gIuAYfOpfID6GjGW7iT32n0BF]
2016-04-16 21:49:42.328 TRACE o.o.b.n.i.m.AbstractRequest[:131]- About to execute 'https://api.home.nest.com/oauth2/access_token?code=R2QAP792&client_id=:e3d582f6-4fd1-43fb-8fa4-6500bf2ca28a&client_secret=gIuAYfOpfID6GjGW7iT32n0BF&grant_type=authorization_code'
2016-04-16 21:49:43.019 WARN  o.o.b.n.i.m.AbstractRequest[:153]- Method failed: HTTP/1.1 403 Forbidden
2016-04-16 21:49:43.024 TRACE o.o.b.n.i.m.AbstractRequest[:172]- {"error":"client_not_active","error_description":"client is not active","instance_id":"5c6e72f2-cb72-4e72-a21c-3e115538d35b"}
2016-04-16 21:49:43.106 TRACE o.o.b.n.internal.NestBinding[:619]- Response: AccessTokenResponse[accessToken=<null>,expiresIn=<null>,error=client_not_active,errorDescription=client is not active]
2016-04-16 21:49:43.106 ERROR o.o.b.n.internal.NestBinding[:622]- Error retrieving access token: AccessTokenResponse[accessToken=<null>,expiresIn=<null>,error=client_not_active,errorDescription=client is not active]'
2016-04-16 21:49:43.106 WARN  o.o.b.n.internal.NestBinding[:163]- Periodic poll skipped.

Error seems pretty self explanatory!

However…
If I request the access token ‘manually’ I get a token without problems.

curl -X POST “https://api.home.nest.com/oauth2/access_token” -d “code=R2QAP792,” -d “client_id=e3d582f6-4fd1-43fb-8fa4-6500bf2ca28a” -d “client_secret=gIuAYfOpfID6GjGW7iT32n0BF” -d “grant_type=authorization_code”

Response:
{“access_token”:“c.tCvNemRiYzCAT2b9ONr8U0z6EZ91iPiI0IL35iPoNfIGi1KnHm2xaj32qePPBemPl7xgDkU7hv1M8dmuWyEJU3MgnHf2sCphc6peTZkx2GDreK86cN7Kxxi4F9SSrh60llwadjsQULlUCMRh”,“expires_in”:315360000}

Anybody recognizes this error? Help appreciated!
I browsed through the code and believe the token is stored in the preferences? tried to add it manually to bypass the access token request but to no avail…

Thanks!

Hi All,

Just to let everybody know that I finally got the Nest binding up and running.
Rather ‘dirty’ workaround :frowning:

I put the manually requested access token in the sourcecode (AccessTokenResponse Class) so the bundle thinks it has received a valid token.

Dropped the jar in openHab and now it’s working.

Since all is working now it seems that the generated HTTP call to request the access_token is not correct?
Maybe a slight change on the Nest side?

will do some more research.

All, I get the same nest authorization error if I run openhab as a service (user openhab). Starting openhab via start.sh (as root) seems to work ok. Any thoughs as I am stuck?

Somehow there is a : that appears at the beginning of the value for clientId that is not there when you manually obtain the token. Is there any chance that there is a typo in your openhab.cfg or nest.cfg file that inadvertently contains a : character where it shouldn’t be?

Is it possible that, when running openHAB as a service, it is referring to a different .cfg file than when you run openHAB from start.sh? I install openHAB via apt-get, and in that installation I do not have a start.sh to run. This suggests to me that you have a “non-standard” installation of openHAB, which might mean than you have more than one set of configuration files.

Hi Watou, I think you are right. I’ve reinstalled (apt-get) openhab on a new raspberry pi 3 with the same configuration and so far so good. Thanks for the hint.