{"action":"created","issue":{"url":"https://api.github.com/repos/nylas/nylas-nodejs/issues/1","labels_url":"https://api.github.com/repos/nylas/nylas-nodejs/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/nylas/nylas-nodejs/issues/1/comments","events_url":"https://api.github.com/repos/nylas/nylas-nodejs/issues/1/events","html_url":"https://github.com/nylas/nylas-nodejs/issues/1","id":68456119,"number":1,"title":"Problem with accounts endpoint","user":{"login":"misticini","id":4440734,"avatar_url":"https://avatars.githubusercontent.com/u/4440734?v=3","gravatar_id":"","url":"https://api.github.com/users/misticini","html_url":"https://github.com/misticini","followers_url":"https://api.github.com/users/misticini/followers","following_url":"https://api.github.com/users/misticini/following{/other_user}","gists_url":"https://api.github.com/users/misticini/gists{/gist_id}","starred_url":"https://api.github.com/users/misticini/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/misticini/subscriptions","organizations_url":"https://api.github.com/users/misticini/orgs","repos_url":"https://api.github.com/users/misticini/repos","events_url":"https://api.github.com/users/misticini/events{/privacy}","received_events_url":"https://api.github.com/users/misticini/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-14T18:00:32Z","updated_at":"2015-04-14T20:47:18Z","closed_at":null,"body":"Hello,\r\n\r\nI'm using Nylas-nodejs sdk and i've detected a bug. \r\n\r\nI'm trying to get the accounts with:\r\n\r\n```\r\nNylas.with(ApiToken).accounts.list().then(function(accounts) {\r\n}); \r\n```\r\nBut this functionality have a bunch of bugs. I've patch the NylasSDK but only on Javascript source (not on coffeescript) but i will list the problems that make this not work:\r\n\r\n1- \r\n\r\nOn management-model-collection.js the code was:\r\n```\r\nManagementModelCollection.prototype.path = function() {\r\n      return \"/a/\" + this.api.appId+ \"/accounts\";\r\n    };\r\n```\r\nThis not work because api isnt a defined attribute.\r\n\r\nI've patched this to:\r\n\r\n```\r\nManagementModelCollection.prototype.path = function() {\r\n      Nylas = require('../nylas');\r\n      return \"/a/\" + Nylas.appId+ \"/accounts\";\r\n    };\r\n```\r\n\r\n2- \r\nOn nylas-connection.js the code on line 41 was:\r\n```\r\nif (options.json == null) {\r\n        options.json = true;\r\n      }\r\n if (this.accessToken) {\r\n        options.auth = {\r\n          'user': this.accessToken,\r\n          'pass': '',\r\n          'sendImmediately': true\r\n        };\r\n}\r\n```\r\nI've patched this  to:\r\n\r\n```\r\nif (options.json == null) {\r\n        options.json = true;\r\n      }\r\n      if (options.path.substr(0,3) === '/a/' ) {\r\n        options.auth = {\r\n          'user': Nylas.appSecret,\r\n          'pass': '',\r\n          'sendImmediately': true\r\n        };\r\n      }\r\n      else if (this.accessToken) {\r\n        options.auth = {\r\n          'user': this.accessToken,\r\n          'pass': '',\r\n          'sendImmediately': true\r\n        };\r\n      }\r\n```\r\n\r\nI can made a patch in coffeescript source and make a pull request, but i think that with all explained its better to nylas team corrected this bug on your way :)\r\n\r\nRegards\r\n"},"comment":{"url":"https://api.github.com/repos/nylas/nylas-nodejs/issues/comments/93054923","html_url":"https://github.com/nylas/nylas-nodejs/issues/1#issuecomment-93054923","issue_url":"https://api.github.com/repos/nylas/nylas-nodejs/issues/1","id":93054923,"user":{"login":"bengotow","id":1037212,"avatar_url":"https://avatars.githubusercontent.com/u/1037212?v=3","gravatar_id":"","url":"https://api.github.com/users/bengotow","html_url":"https://github.com/bengotow","followers_url":"https://api.github.com/users/bengotow/followers","following_url":"https://api.github.com/users/bengotow/following{/other_user}","gists_url":"https://api.github.com/users/bengotow/gists{/gist_id}","starred_url":"https://api.github.com/users/bengotow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bengotow/subscriptions","organizations_url":"https://api.github.com/users/bengotow/orgs","repos_url":"https://api.github.com/users/bengotow/repos","events_url":"https://api.github.com/users/bengotow/events{/privacy}","received_events_url":"https://api.github.com/users/bengotow/received_events","type":"User","site_admin":false},"created_at":"2015-04-14T20:47:18Z","updated_at":"2015-04-14T20:47:18Z","body":"Hi @misticini thanks for reporting these issues! I'll take a look. In #1, it looks like the path should reference `this.connection` and not `this.api`. I think in the second one you're totally right—the access token is used for most requests, but the accounts endpoint uses the app secret. I can modify the coffeescript and add test cases for these. Stay tuned!"}}