openhab / openhab-addons

Add-ons for openHAB
https://www.openhab.org/
Eclipse Public License 2.0
1.86k stars 3.56k forks source link

[ecobee] grant type refresh_token to URL https://api.ecobee.com/token failed with error code invalid_grant #8720

Closed morph166955 closed 3 years ago

morph166955 commented 3 years ago

I've been seeing the following error for about a week now and have been unable to resolve:

2020-10-10 11:54:19.459 [ERROR] [oauth2client.internal.OAuthConnector] - grant type refresh_token to URL https://api.ecobee.com/token failed with error code invalid_grant, description The authorization grant, token or credentials are invalid, expired, revoked, do not match the redirection URI used in the authorization request, or was issued to another client. 2020-10-10 11:54:19.464 [INFO ] [inding.ecobee.internal.api.EcobeeApi] - API: Exception getting access token: error='invalid_grant', description='The authorization grant, token or credentials are invalid, expired, revoked, do not match the redirection URI used in the authorization request, or was issued to another client.'

I've rebuilt the ecobee.com side and put the new apikey into the .things file. I've restarted OH2 many times at this point. Some posts suggested to delete "~/.java/.userPrefs", this also did not help. I have not found a way to get OH to generate a new PIN request.

EDIT: I'm on OH 2.5.7 and running the new v2 ecobee binding.

mhilbush commented 3 years ago

No idea why that's happening @morph166955. You might want to post on the Ecobee binding thread on the forum, as more people will see your post.

In the meantime, I'll look into the cause of the invalid_grant error.

morph166955 commented 3 years ago

I was able to look at this today a little. Deleting StorageHandler.For.OAuthClientService.json in /var/lib/openhab2/jsondb as well as all the backups fixed the issue. This wasn't a huge deal for me as ecobee is the only thing that I have that uses this but it's obviously not the best answer.

mhilbush commented 3 years ago

I considered suggesting that you delete that file, but I didn't consider it an acceptable resolution of the problem. It's too bad you did that, as I built a version of the binding that deletes the OAuth credentials upon receipt of the invalid_grant error. It would've been nice for you to be able to test out that version.