Skip to content

Commit

Permalink
Fix periodic authentication issue in refreshToken mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
adriancable committed Sep 28, 2021
1 parent bf71aff commit e8312d9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![verified-by-homebridge](https://badgen.net/badge/homebridge/verified/purple)](https://github.com/homebridge/homebridge/wiki/Verified-Plugins)
[![Discord](https://img.shields.io/discord/432663330281226270?color=728ED5&logo=discord&label=discord)](https://discord.gg/j5WwJTB)

Nest plug-in for [Homebridge](https://github.com/nfarina/homebridge) using the native Nest API. See what's new in [release 4.6.1](https://github.com/chrisjshull/homebridge-nest/releases/tag/v4.6.1).
Nest plug-in for [Homebridge](https://github.com/nfarina/homebridge) using the native Nest API. See what's new in [release 4.6.2](https://github.com/chrisjshull/homebridge-nest/releases/tag/v4.6.2).

Integrate your Nest Thermostat, Temperature Sensors, Nest Protect, and Nest x Yale Lock devices into your HomeKit system. Both Nest Accounts (pre-August 2019) and Google Accounts are supported.

Expand Down
10 changes: 5 additions & 5 deletions lib/nest-connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class Connection {
if (this.config.googleAuth) {
let issueToken = this.config.googleAuth.issueToken;
let cookies = this.config.googleAuth.cookies;

req = {
method: 'GET',
// followAllRedirects: true,
Expand All @@ -169,7 +169,7 @@ class Connection {
}
};
result = (await axios(req)).data;
googleAccessToken = result.access_token;
googleAccessToken = result.access_token;
} else if (this.config.refreshToken) {
req = {
method: 'POST',
Expand Down Expand Up @@ -275,7 +275,7 @@ class Connection {
'cookie': 'G_ENABLED_IDPS=google; eu_cookie_accepted=1; viewer-volume=0.5; cztoken=' + this.config.access_token
}
};
} else if (!this.config.googleAuth && !this.config.authenticator) {
} else if (!this.config.googleAuth && !this.config.refreshToken && !this.config.authenticator) {
this.error('Nest account login by username/password is no longer supported.');
return false;

Expand Down Expand Up @@ -336,7 +336,7 @@ class Connection {
}

try {
if (!this.config.authenticator && !this.config.googleAuth && !this.config.access_token && (!rcToken || !rcKey)) {
if (!this.config.authenticator && !this.config.refreshToken && !this.config.googleAuth && !this.config.access_token && (!rcToken || !rcKey)) {
// Recaptcha failed - throw
throw({code: 'ENORECAPTCHA'});
}
Expand Down Expand Up @@ -420,7 +420,7 @@ class Connection {
}
}

let isGoogle = this.config.googleAuth || this.config.authenticator;
let isGoogle = this.config.refreshToken || this.config.googleAuth || this.config.authenticator;
// Google tokens expire after 60 minutes (Nest is 30 days), so refresh just before that to make sure we always have a fresh token
if (this.preemptiveReauthTimer) {
clearTimeout(this.preemptiveReauthTimer);
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@
"prepublishOnly": "npm run lint",
"preversion": "npm run lint"
},
"version": "4.6.1",
"version": "4.6.2",
"warnings": [
{
"code": "ENOTSUP",
"required": {
"node": ">=7.0.0",
"homebridge": ">=0.2.5"
},
"pkgid": "[email protected].1"
"pkgid": "[email protected].2"
}
]
}

0 comments on commit e8312d9

Please sign in to comment.