mhilbush
(Mark)
June 29, 2022, 12:49pm
60
rubens:
After seeing the failure on M7 this morning I did a restart, generated a new authCode, put that in and voice say test worked again from console.
So I re-installed 3.3.0-1, starting up googletts did not work, so generated a new authCode, put that in and voice say test worked again from console.
Thus, my impression that the released version comes with completly broken googletts was wrong.
Still, the outh2 authentication appears to be super fragile and the process to renew it with copying the authCode from the address line feels clumsy, to put it mildly.
Not sure of it’s relevant here, but I ran into an issue with reauthorizations after the first auth is a problem because the refresh token is returned only after the first authorization. The net effect is that it works until the access token needs to be refreshed (about an hour), then it breaks.
I pushed this change for the nest binding, but may be relevant for Google TTS, too. Note the addition of &prompt=consent to the URL.
main ← mhilbush:nest-refresh-token
opened 02:30PM - 10 May 22 UTC
By default, the Google OAuth API returns the refresh token only on the first aut… horization. On subsequent authorizations using the same Client ID and Secret, Google does not return the refresh token in the access token response. This causes the binding to fail on the first refresh of the access token after a reauthorization.
This affects the SDM and Pub/Sub APIs. However, the failure is more spectacular with the Pub/Sub API as it causes the binding to repeatedly do a pub/sub request against the Google API every 20-40 msec.
This PR adds a new query parameter (prompt=consent) to the URL used to get the authorization code. This parameter causes Google to always return the refresh token in the authorization response (via `oAuthService.getAccessTokenResponseByAuthorizationCode`).
In addition, this PR adds checks to make sure the refresh token in present in the access token response in order to fail more quickly and gracefully if the refresh token is missing.
Further details of my analysis are here.
https://community.openhab.org/t/nest-binding-throwing-pub-sub-errors-repeatedly/135721
I know @wborn is pretty time-constrained right now, but I'm hopeful he can find a few minutes to review. 😉
Signed-off-by: Mark Hilbush <mark@hilbush.com>
Edit: I should note that this problem drove me absolutely crazy for days. I would do a reauth, then it would work for a while, then it would break. Rinse and repeat. Finally figured it out.