homebridge-nest icon indicating copy to clipboard operation
homebridge-nest copied to clipboard

Error: Unauthorized

Open steinmanal opened this issue 8 years ago • 5 comments

I think I might have failed on step 14 during installation. I think I may have had the token in the config.json file while running Homebridge.

Now, when I run Homebridge I get the following errors:

{ Error: UNAUTHORIZED: {"error":"unauthorized","type":"https://developer.nest.com/documentation/cloud/error-messages#auth-error","message":"unauthorized","instance":"aeaf048c-d733-4454-8f57-60fc6ef31b69"} at Yg (/usr/local/lib/node_modules/homebridge-nest/node_modules/firebase/lib/firebase-node.js:150:468) at Object.Cc (/usr/local/lib/node_modules/homebridge-nest/node_modules/firebase/lib/firebase-node.js:149:255) at /usr/local/lib/node_modules/homebridge-nest/node_modules/firebase/lib/firebase-node.js:182:177 at Rh.h.Jd (/usr/local/lib/node_modules/homebridge-nest/node_modules/firebase/lib/firebase-node.js:186:104) at Fh.Jd (/usr/local/lib/node_modules/homebridge-nest/node_modules/firebase/lib/firebase-node.js:176:364) at wh.Jg (/usr/local/lib/node_modules/homebridge-nest/node_modules/firebase/lib/firebase-node.js:174:280) at zh (/usr/local/lib/node_modules/homebridge-nest/node_modules/firebase/lib/firebase-node.js:168:464) at Client.Ka.onmessage (/usr/local/lib/node_modules/homebridge-nest/node_modules/firebase/lib/firebase-node.js:167:321) at Client.dispatchEvent (/usr/local/lib/node_modules/homebridge-nest/node_modules/firebase/node_modules/faye-websocket/lib/faye/websocket/api/event_target.js:22:30) at Client._receiveMessage (/usr/local/lib/node_modules/homebridge-nest/node_modules/firebase/node_modules/faye-websocket/lib/faye/websocket/api.js:134:10) at Client. (/usr/local/lib/node_modules/homebridge-nest/node_modules/firebase/node_modules/faye-websocket/lib/faye/websocket/api.js:34:49) at emitOne (events.js:101:20) at Client.emit (events.js:188:7) at Client. (/usr/local/lib/node_modules/homebridge-nest/node_modules/firebase/node_modules/faye-websocket/node_modules/websocket-driver/lib/websocket/driver/hybi.js:451:14) at pipe (/usr/local/lib/node_modules/homebridge-nest/node_modules/firebase/node_modules/faye-websocket/node_modules/websocket-driver/node_modules/websocket-extensions/lib/pipeline/index.js:37:40) at Pipeline._loop (/usr/local/lib/node_modules/homebridge-nest/node_modules/firebase/node_modules/faye-websocket/node_modules/websocket-driver/node_modules/websocket-extensions/lib/pipeline/index.js:44:3) at Pipeline.processIncomingMessage (/usr/local/lib/node_modules/homebridge-nest/node_modules/firebase/node_modules/faye-websocket/node_modules/websocket-driver/node_modules/websocket-extensions/lib/pipeline/index.js:13:8) at Extensions.processIncomingMessage (/usr/local/lib/node_modules/homebridge-nest/node_modules/firebase/node_modules/faye-websocket/node_modules/websocket-driver/node_modules/websocket-extensions/lib/websocket_extensions.js:133:20) at Client._emitMessage (/usr/local/lib/node_modules/homebridge-nest/node_modules/firebase/node_modules/faye-websocket/node_modules/websocket-driver/lib/websocket/driver/hybi.js:442:22) at Client._emitFrame (/usr/local/lib/node_modules/homebridge-nest/node_modules/firebase/node_modules/faye-websocket/node_modules/websocket-driver/lib/websocket/driver/hybi.js:405:19) at Client.parse (/usr/local/lib/node_modules/homebridge-nest/node_modules/firebase/node_modules/faye-websocket/node_modules/websocket-driver/lib/websocket/driver/hybi.js:144:18) at Client.parse (/usr/local/lib/node_modules/homebridge-nest/node_modules/firebase/node_modules/faye-websocket/node_modules/websocket-driver/lib/websocket/driver/client.js:56:58) cause: { Error: UNAUTHORIZED: {"error":"unauthorized","type":"https://developer.nest.com/documentation/cloud/error-messages#auth-error","message":"unauthorized","instance":"aeaf048c-d733-4454-8f57-60fc6ef31b69"} at Yg (/usr/local/lib/node_modules/homebridge-nest/node_modules/firebase/lib/firebase-node.js:150:468) at Object.Cc (/usr/local/lib/node_modules/homebridge-nest/node_modules/firebase/lib/firebase-node.js:149:255) at /usr/local/lib/node_modules/homebridge-nest/node_modules/firebase/lib/firebase-node.js:182:177 at Rh.h.Jd (/usr/local/lib/node_modules/homebridge-nest/node_modules/firebase/lib/firebase-node.js:186:104) at Fh.Jd (/usr/local/lib/node_modules/homebridge-nest/node_modules/firebase/lib/firebase-node.js:176:364) at wh.Jg (/usr/local/lib/node_modules/homebridge-nest/node_modules/firebase/lib/firebase-node.js:174:280) at zh (/usr/local/lib/node_modules/homebridge-nest/node_modules/firebase/lib/firebase-node.js:168:464) at Client.Ka.onmessage (/usr/local/lib/node_modules/homebridge-nest/node_modules/firebase/lib/firebase-node.js:167:321) at Client.dispatchEvent (/usr/local/lib/node_modules/homebridge-nest/node_modules/firebase/node_modules/faye-websocket/lib/faye/websocket/api/event_target.js:22:30) at Client._receiveMessage (/usr/local/lib/node_modules/homebridge-nest/node_modules/firebase/node_modules/faye-websocket/lib/faye/websocket/api.js:134:10) at Client. (/usr/local/lib/node_modules/homebridge-nest/node_modules/firebase/node_modules/faye-websocket/lib/faye/websocket/api.js:34:49) at emitOne (events.js:101:20) at Client.emit (events.js:188:7) at Client. (/usr/local/lib/node_modules/homebridge-nest/node_modules/firebase/node_modules/faye-websocket/node_modules/websocket-driver/lib/websocket/driver/hybi.js:451:14) at pipe (/usr/local/lib/node_modules/homebridge-nest/node_modules/firebase/node_modules/faye-websocket/node_modules/websocket-driver/node_modules/websocket-extensions/lib/pipeline/index.js:37:40) at Pipeline._loop (/usr/local/lib/node_modules/homebridge-nest/node_modules/firebase/node_modules/faye-websocket/node_modules/websocket-driver/node_modules/websocket-extensions/lib/pipeline/index.js:44:3) at Pipeline.processIncomingMessage (/usr/local/lib/node_modules/homebridge-nest/node_modules/firebase/node_modules/faye-websocket/node_modules/websocket-driver/node_modules/websocket-extensions/lib/pipeline/index.js:13:8) at Extensions.processIncomingMessage (/usr/local/lib/node_modules/homebridge-nest/node_modules/firebase/node_modules/faye-websocket/node_modules/websocket-driver/node_modules/websocket-extensions/lib/websocket_extensions.js:133:20) at Client._emitMessage (/usr/local/lib/node_modules/homebridge-nest/node_modules/firebase/node_modules/faye-websocket/node_modules/websocket-driver/lib/websocket/driver/hybi.js:442:22) at Client._emitFrame (/usr/local/lib/node_modules/homebridge-nest/node_modules/firebase/node_modules/faye-websocket/node_modules/websocket-driver/lib/websocket/driver/hybi.js:405:19) at Client.parse (/usr/local/lib/node_modules/homebridge-nest/node_modules/firebase/node_modules/faye-websocket/node_modules/websocket-driver/lib/websocket/driver/hybi.js:144:18) at Client.parse (/usr/local/lib/node_modules/homebridge-nest/node_modules/firebase/node_modules/faye-websocket/node_modules/websocket-driver/lib/websocket/driver/client.js:56:58) code: 'UNAUTHORIZED' }, isOperational: true, code: 'UNAUTHORIZED' } [1/7/2017, 3:11:48 PM] Falling back to legacy API.

steinmanal avatar Jan 07 '17 20:01 steinmanal

Easy to fix: edit your config.json and remove the token (but make sure you have the code you got from the nest website), restart homebridge and you should see a log message like this:

[1/7/2017, 11:04:11 PM] CODE IS ONLY VALID ONCE! Update config to use {'token':'c.vkK123459835692835629385729385729385729385729385729358723598rN'}

Then you can edit config.json one more time, delete the code, and add the token with double quotes like this:

"token" : "c.vkK123459835692835629385729385729385729385729385729358723598rN"

Muzach avatar Jan 08 '17 07:01 Muzach

Thanks! That worked!

Alex Steinman

On Jan 8, 2017, 2:16 AM -0500, Zach Friedland [email protected], wrote:

Easy to fix: edit your config.json and remove the token (but make sure you have the code you got from the nest website), restart homebridge and you should see a log message like this: [1/7/2017, 11:04:11 PM] CODE IS ONLY VALID ONCE! Update config to use {'token':'c.vkK123459835692835629385729385729385729385729385729358723598rN'} Then you can edit config.json one more time, delete the code, and add the token with double quotes like this: "token" : "c.vkK123459835692835629385729385729385729385729385729358723598rN" — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

steinmanal avatar Jan 10 '17 01:01 steinmanal

Hello,

I am new to Homebridge and the Nest plugin but have tried to figure out how to find the generated token that is being referred to in this thread and Step 14 of the README but cannot do so.

Below is the output I get when I have put in a new code from the Nest development page link into my config.json, and leave out the line with the "token." I believe the next step is to find the token generated and thus edit the config.json with that token to add the "token" line however I do not know in what log to find this token as alluded to above.

Any assistance would be greatly appreciated.

Here is my config.json:

`{ "bridge": { "name": "Homebridge", "username": "B8:27:EB:C1:25:4D", "port": 46521 "pin": "031-45-154" },

"platforms": [{
		"platform": "Nest",



		"clientId": "4235bef0-8001-47cb-b2f0-449ae7eeb8a3",
		"clientSecret": "df0zl5FMDGDkznBiPBc7vGxr7G",
		"code": "8ZPRDDCZ",
  "username": "username",
  "password": "password"
	},
	{
		"platform": "config",
		"name": "Config",
		"port": 8080,
		"log": "/var/log/homebridge.stdout.log",
		"error_log": "/var/log/homebridge.stderr.log",
		"restart": "/usr/local/bin/supervisorctl restart homebridge"
	}
]

}`

Output:

`[2017-10-30 02:39:31] [Nest] Initializing Nest platform... [2017-10-30 02:39:31] [Nest] Fetching Nest devices. [2017-10-30 02:39:31] [Config] Initializing config platform... [2017-10-30 02:39:33] [Config] Console is listening on port 8080. [2017-10-30 02:39:34] [Nest] Auth failed which likely means the code is no longer valid. Should be able to generate a new one at https://home.nest.com/login/oauth2?client_id=4235bef0-8001-47cb-b2f0-449ae7eeb8a3&state=STATE [2017-10-30 02:39:34] [Nest] { StatusCodeError: 400 - {"error":"oauth2_error","error_description":"client secret not found","instance_id":"df7c7b95-4d6d-4fb0-8045-1d4bb5cba9c9"} at new StatusCodeError (/usr/lib/node_modules/homebridge-nest/node_modules/request-promise/lib/errors.js:26:15) at Request.RP$callback [as _callback] (/usr/lib/node_modules/homebridge-nest/node_modules/request-promise/lib/rp.js:68:32) at Request.self.callback (/usr/lib/node_modules/homebridge-nest/node_modules/request/request.js:186:22) at emitTwo (events.js:125:13) at Request.emit (events.js:213:7) at Request. (/usr/lib/node_modules/homebridge-nest/node_modules/request/request.js:1163:10) at emitOne (events.js:115:13) at Request.emit (events.js:210:7) at IncomingMessage. (/usr/lib/node_modules/homebridge-nest/node_modules/request/request.js:1085:12) at Object.onceWrapper (events.js:312:30) at emitNone (events.js:110:20) at IncomingMessage.emit (events.js:207:7) at endReadableNT (_stream_readable.js:1056:12) at _combinedTickCallback (internal/process/next_tick.js:138:11) at process._tickCallback (internal/process/next_tick.js:180:9) name: 'StatusCodeError', statusCode: 400, message: '400 - {"error":"oauth2_error","error_description":"client secret not found","instance_id":"df7c7b95-4d6d-4fb0-8045-1d4bb5cba9c9"}', error: '{"error":"oauth2_error","error_description":"client secret not found","instance_id":"df7c7b95-4d6d-4fb0-8045-1d4bb5cba9c9"}', options: { method: 'POST', uri: 'https://api.home.nest.com/oauth2/access_token', form: { client_id: '4235bef0-8001-47cb-b2f0-449ae7eeb8a3', client_secret: 'df0zl5FMDGDkznBiPBc7vGxr7G', code: '8ZPRDDCZ', grant_type: 'authorization_code' }, callback: undefined, transform: undefined, simple: true, resolveWithFullResponse: false }, response: IncomingMessage { _readableState: ReadableState { objectMode: false, highWaterMark: 16384, buffer: [Object], length: 0, pipes: null, pipesCount: 0, flowing: true, ended: true, endEmitted: true, reading: false, sync: true, needReadable: false, emittedReadable: false, readableListening: false, resumeScheduled: false, destroyed: false, defaultEncoding: 'utf8', awaitDrain: 0, readingMore: false, decoder: null, encoding: null }, readable: false, domain: null, _events: { end: [Array], close: [Array], data: [Function], error: [Function] }, _eventsCount: 4, _maxListeners: undefined, socket: TLSSocket { _tlsOptions: [Object], _secureEstablished: true, _securePending: false, _newSessionPending: false, _controlReleased: true, _SNICallback: null, servername: null, npnProtocol: undefined, alpnProtocol: false, authorized: true, authorizationError: null, encrypted: true, _events: [Object], _eventsCount: 9, connecting: false, _hadError: false, _handle: null, _parent: null, _host: 'api.home.nest.com', _readableState: [Object], readable: false, domain: null, _maxListeners: undefined, _writableState: [Object], writable: false, allowHalfOpen: false, _bytesDispatched: 283, _sockname: null, _pendingData: null, _pendingEncoding: '', server: undefined, _server: null, ssl: null, _requestCert: true, _rejectUnauthorized: true, parser: null, _httpMessage: [Object], read: [Function], _consuming: true, _idleNext: null, _idlePrev: null, _idleTimeout: -1, [Symbol(asyncId)]: 29, [Symbol(bytesRead)]: 223 }, connection: TLSSocket { _tlsOptions: [Object], _secureEstablished: true, _securePending: false, _newSessionPending: false, _controlReleased: true, _SNICallback: null, servername: null, npnProtocol: undefined, alpnProtocol: false, authorized: true, authorizationError: null, encrypted: true, _events: [Object], _eventsCount: 9, connecting: false, _hadError: false, _handle: null, _parent: null, _host: 'api.home.nest.com', _readableState: [Object], readable: false, domain: null, _maxListeners: undefined, _writableState: [Object], writable: false, allowHalfOpen: false, _bytesDispatched: 283, _sockname: null, _pendingData: null, _pendingEncoding: '', server: undefined, _server: null, ssl: null, _requestCert: true, _rejectUnauthorized: true, parser: null, _httpMessage: [Object], read: [Function], _consuming: true, _idleNext: null, _idlePrev: null, _idleTimeout: -1, [Symbol(asyncId)]: 29, [Symbol(bytesRead)]: 223 }, httpVersionMajor: 1, httpVersionMinor: 1, httpVersion: '1.1', complete: true, headers: { 'content-type': 'application/json', 'content-length': '123', connection: 'Close' }, rawHeaders: [ 'Content-Type', 'application/json', 'Content-Length', '123', 'Connection', 'Close' ], trailers: {}, rawTrailers: [], upgrade: false, url: '', method: null, statusCode: 400, statusMessage: 'Bad Request', client: TLSSocket { _tlsOptions: [Object], _secureEstablished: true, _securePending: false, _newSessionPending: false, _controlReleased: true, _SNICallback: null, servername: null, npnProtocol: undefined, alpnProtocol: false, authorized: true, authorizationError: null, encrypted: true, _events: [Object], _eventsCount: 9, connecting: false, _hadError: false, _handle: null, _parent: null, _host: 'api.home.nest.com', _readableState: [Object], readable: false, domain: null, _maxListeners: undefined, _writableState: [Object], writable: false, allowHalfOpen: false, _bytesDispatched: 283, _sockname: null, _pendingData: null, _pendingEncoding: '', server: undefined, _server: null, ssl: null, _requestCert: true, _rejectUnauthorized: true, parser: null, _httpMessage: [Object], read: [Function], _consuming: true, _idleNext: null, _idlePrev: null, _idleTimeout: -1, [Symbol(asyncId)]: 29, [Symbol(bytesRead)]: 223 }, _consuming: true, _dumped: false, req: ClientRequest { domain: null, _events: [Object], _eventsCount: 5, _maxListeners: undefined, output: [], outputEncodings: [], outputCallbacks: [], outputSize: 0, writable: true, _last: true, upgrading: false, chunkedEncoding: false, shouldKeepAlive: false, useChunkedEncodingByDefault: true, sendDate: false, _removedConnection: false, _removedContLen: false, _removedTE: false, _contentLength: null, _hasBody: true, _trailer: '', finished: true, _headerSent: true, socket: [Object], connection: [Object], _header: 'POST /oauth2/access_token HTTP/1.1\r\nhost: api.home.nest.com\r\ncontent-type: application/x-www-form-urlencoded\r\ncontent-length: 131\r\nConnection: close\r\n\r\n', _onPendingData: [Function: noopPendingOutput], agent: [Object], socketPath: undefined, timeout: undefined, method: 'POST', path: '/oauth2/access_token', _ended: true, res: [Circular], aborted: undefined, timeoutCb: null, upgradeOrConnect: false, parser: null, maxHeadersCount: null, [Symbol(outHeadersKey)]: [Object] }, request: Request { domain: null, _events: [Object], _eventsCount: 5, _maxListeners: undefined, method: 'POST', uri: [Object], readable: true, writable: true, explicitMethod: true, _qs: [Object], _auth: [Object], _oauth: [Object], _multipart: [Object], _redirect: [Object], _tunnel: [Object], _rp_resolve: [Function], _rp_reject: [Function], _rp_promise: [Object], _rp_callbackOrig: undefined, callback: [Function], _rp_options: [Object], headers: [Object], setHeader: [Function], hasHeader: [Function], getHeader: [Function], removeHeader: [Function], localAddress: undefined, pool: {}, dests: [], __isRequestRequest: true, _callback: [Function: RP$callback], proxy: null, tunnel: true, setHost: true, originalCookieHeader: undefined, _disableCookies: true, _jar: undefined, port: 443, host: 'api.home.nest.com', body: 'client_id=4235bef0-8001-47cb-b2f0-449ae7eeb8a3&client_secret=df0zl5FMDGDkznBiPBc7vGxr7G&code=8ZPRDDCZ&grant_type=authorization_code', path: '/oauth2/access_token', httpModule: [Object], agentClass: [Object], agent: [Object], _started: true, href: 'https://api.home.nest.com/oauth2/access_token', req: [Object], ntick: true, response: [Circular], originalHost: 'api.home.nest.com', originalHostHeaderName: 'host', responseContent: [Circular], _destdata: true, _ended: true, _callbackCalled: true }, toJSON: [Function: responseToJSON], caseless: Caseless { dict: [Object] }, read: [Function], body: '{"error":"oauth2_error","error_description":"client secret not found","instance_id":"df7c7b95-4d6d-4fb0-8045-1d4bb5cba9c9"}' } } Scan this code with your HomeKit App on your iOS device to pair with Homebridge:

┌────────────┐     
│ 031-45-154 │     
└────────────┘     
                   

[2017-10-30 02:39:34] Homebridge is running on port 46521. `

syncsh1ps avatar Oct 30 '17 02:10 syncsh1ps

I have the same thing and stuck in the cycle of generating a new code, adding it to config.json file, restarting Homebridge, and the cycle continues. If anyone can help I would greatly appreciate it.

FOLLOWUP: I didn't realize that I needed to have "token" : "token number" in my json file. I had the token # where the code had been. Once I figured that out I am good to go.

AAShepAA avatar Jun 15 '18 18:06 AAShepAA

This is no longer the canonical repo for this module. Please file a bug here: https://github.com/chrisjshull/homebridge-nest/issues/new/choose

chrisjshull avatar Jun 15 '18 19:06 chrisjshull