-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[nest] Fix for missing refresh token after reauthorization #12711
Conversation
Signed-off-by: Mark Hilbush <mark@hilbush.com>
I do not see in the code the addition of the prompt query parameter. |
That's correct. It's not in the code, but only in the URL in the documentation. You need to copy/paste the URL from the documentation into your browser's address bar, then replace the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I let a chance to @wborn to review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix!
This pull request has been mentioned on openHAB Community. There might be relevant details there: https://community.openhab.org/t/openhab-3-3-release-discussion/136925/60 |
…2711) Signed-off-by: Mark Hilbush <mark@hilbush.com>
…2711) Signed-off-by: Mark Hilbush <mark@hilbush.com> Signed-off-by: Andras Uhrin <andras.uhrin@gmail.com>
…2711) Signed-off-by: Mark Hilbush <mark@hilbush.com>
By default, the Google OAuth API returns the refresh token only on the first authorization. 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