{"action":"created","issue":{"url":"https://api.github.com/repos/box/box-node-sdk/issues/157","repository_url":"https://api.github.com/repos/box/box-node-sdk","labels_url":"https://api.github.com/repos/box/box-node-sdk/issues/157/labels{/name}","comments_url":"https://api.github.com/repos/box/box-node-sdk/issues/157/comments","events_url":"https://api.github.com/repos/box/box-node-sdk/issues/157/events","html_url":"https://github.com/box/box-node-sdk/issues/157","id":245178474,"number":157,"title":"Intermittent Expired Auth error","user":{"login":"monofuel","id":1392843,"avatar_url":"https://avatars3.githubusercontent.com/u/1392843?v=4","gravatar_id":"","url":"https://api.github.com/users/monofuel","html_url":"https://github.com/monofuel","followers_url":"https://api.github.com/users/monofuel/followers","following_url":"https://api.github.com/users/monofuel/following{/other_user}","gists_url":"https://api.github.com/users/monofuel/gists{/gist_id}","starred_url":"https://api.github.com/users/monofuel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monofuel/subscriptions","organizations_url":"https://api.github.com/users/monofuel/orgs","repos_url":"https://api.github.com/users/monofuel/repos","events_url":"https://api.github.com/users/monofuel/events{/privacy}","received_events_url":"https://api.github.com/users/monofuel/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":11,"created_at":"2017-07-24T19:05:50Z","updated_at":"2017-09-06T18:07:16Z","closed_at":null,"author_association":"NONE","body":"Using the Persistent Client in the box-node-sdk v1.7.0 library.\r\n\r\nWe can authorize successfully and the majority of requests succeed, however we sometimes get 401 Expired Auth errors thrown for api calls in production on GCP.\r\nIt seems to happen at random, and we haven't been able to reproduce it locally.\r\nThe error does not affect any specific files or users. Retrying at a later time usually succeeds.\r\n\r\nHere is a copy of the error being thrown when we try to get folder id 0:\r\n\r\n```\r\n{\r\n   authExpired:  true     \r\n   cause: {\r\n    authExpired:  true      \r\n    response: {\r\n     headers: {\r\n      age:  \"0\"        \r\n      connection:  \"keep-alive\"        \r\n      content-length:  \"0\"        \r\n      date:  \"Mon, 24 Jul 2017 09:10:24 GMT\"        \r\n      server:  \"ATS\"        \r\n      strict-transport-security:  \"max-age=31536000; includeSubDomains\"        \r\n      vary:  \"Accept-Encoding\"        \r\n      www-authenticate:  \"Bearer realm=\"Service\", error=\"invalid_token\", error_description=\"The access token provided is invalid.\"\"        \r\n     }\r\n     request: {\r\n      headers: {\r\n       Authorization:  \"[REMOVED BY SDK]\"         \r\n       User-Agent:  \"Box Node.js SDK v1.7.0\"         \r\n       accept:  \"application/json\"         \r\n      }\r\n      method:  \"GET\"        \r\n      uri: {\r\n       auth:  null         \r\n       hash:  null         \r\n       host:  \"api.box.com\"         \r\n       hostname:  \"api.box.com\"         \r\n       href:  \"https://api.box.com/2.0/folders/0\"         \r\n       path:  \"/2.0/folders/0\"         \r\n       pathname:  \"/2.0/folders/0\"         \r\n       port:  443         \r\n       protocol:  \"https:\"         \r\n       query:  null         \r\n       search:  null         \r\n       slashes:  true         \r\n      }\r\n     }\r\n     statusCode:  401       \r\n    }\r\n    statusCode:  401      \r\n   }\r\n   isOperational:  true     \r\n   response: {\r\n    $ref:  \"$[\"err\"][\"cause\"][\"response\"]\"      \r\n   }\r\n   statusCode:  401     \r\n  }\r\n  ```\r\n  \r\nThis is from our production logs. `response: { $ref }` is actually just a duplicate reference detected by cycles.decycle to the object at err.cause.response.\r\n\r\nthe README.md states that the persistent client should handle refreshing and retrying, so i don't see why it is throwing a 401 back up to our application."},"comment":{"url":"https://api.github.com/repos/box/box-node-sdk/issues/comments/327567005","html_url":"https://github.com/box/box-node-sdk/issues/157#issuecomment-327567005","issue_url":"https://api.github.com/repos/box/box-node-sdk/issues/157","id":327567005,"user":{"login":"monofuel","id":1392843,"avatar_url":"https://avatars3.githubusercontent.com/u/1392843?v=4","gravatar_id":"","url":"https://api.github.com/users/monofuel","html_url":"https://github.com/monofuel","followers_url":"https://api.github.com/users/monofuel/followers","following_url":"https://api.github.com/users/monofuel/following{/other_user}","gists_url":"https://api.github.com/users/monofuel/gists{/gist_id}","starred_url":"https://api.github.com/users/monofuel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monofuel/subscriptions","organizations_url":"https://api.github.com/users/monofuel/orgs","repos_url":"https://api.github.com/users/monofuel/repos","events_url":"https://api.github.com/users/monofuel/events{/privacy}","received_events_url":"https://api.github.com/users/monofuel/received_events","type":"User","site_admin":false},"created_at":"2017-09-06T18:07:16Z","updated_at":"2017-09-06T18:07:16Z","author_association":"NONE","body":"Got the error more this morning. at 7:06am PT, 2 separate servers threw a 401 error when getting a folder, with the error response headers including: `www-authenticate:  \"Bearer realm=\"Service\", error=\"invalid_token\", error_description=\"The access token provided is invalid.\"\"` for both of them.\r\n\r\nright at 7:06:06, one server fetched 4 values and then set 4 values (`BOX_ACCESS_TOKEN`, `BOX_REFRESH_TOKEN`, `BOX_TOKEN_TTLMS` and `BOX_TOKEN_ACQUIRED`) and then immediately after the same node threw a 401 error for getting a folder.\r\n\r\nLater at 7:06:37, a different server did the exact same thing (fetched all 4, updated all 4, and then threw a 401)"}}
{"actor":{"display_login":"monofuel"}}