{"action":"created","issue":{"url":"https://api.github.com/repos/phillipj/node-plex-api/issues/13","labels_url":"https://api.github.com/repos/phillipj/node-plex-api/issues/13/labels{/name}","comments_url":"https://api.github.com/repos/phillipj/node-plex-api/issues/13/comments","events_url":"https://api.github.com/repos/phillipj/node-plex-api/issues/13/events","html_url":"https://github.com/phillipj/node-plex-api/pull/13","id":96674660,"number":13,"title":"WIP: replaced ./auth.js with options.authenticator","user":{"login":"phillipj","id":1231635,"avatar_url":"https://avatars.githubusercontent.com/u/1231635?v=3","gravatar_id":"","url":"https://api.github.com/users/phillipj","html_url":"https://github.com/phillipj","followers_url":"https://api.github.com/users/phillipj/followers","following_url":"https://api.github.com/users/phillipj/following{/other_user}","gists_url":"https://api.github.com/users/phillipj/gists{/gist_id}","starred_url":"https://api.github.com/users/phillipj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phillipj/subscriptions","organizations_url":"https://api.github.com/users/phillipj/orgs","repos_url":"https://api.github.com/users/phillipj/repos","events_url":"https://api.github.com/users/phillipj/events{/privacy}","received_events_url":"https://api.github.com/users/phillipj/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-07-22T21:57:47Z","updated_at":"2015-07-23T07:47:15Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/phillipj/node-plex-api/pulls/13","html_url":"https://github.com/phillipj/node-plex-api/pull/13","diff_url":"https://github.com/phillipj/node-plex-api/pull/13.diff","patch_url":"https://github.com/phillipj/node-plex-api/pull/13.patch"},"body":"This extracts authentication into separate modules, enabling any authentication mechanism to be used.\r\n\r\nFor convenience sake and preventing breaking changes, it uses the newly created [plex-api-credentials](https://www.npmjs.com/package/plex-api-credentials) authenticator module behind the scenes when `options.username` and `options.password` are provided when creating PlexAPI objects.\r\n\r\nAdded a small section about authenticators in Readme.\r\n\r\nThis is supposed to fix the biggest challenges discussed in PR #12.\r\n\r\nAny thoughts out there?"},"comment":{"url":"https://api.github.com/repos/phillipj/node-plex-api/issues/comments/124008335","html_url":"https://github.com/phillipj/node-plex-api/pull/13#issuecomment-124008335","issue_url":"https://api.github.com/repos/phillipj/node-plex-api/issues/13","id":124008335,"user":{"login":"phillipj","id":1231635,"avatar_url":"https://avatars.githubusercontent.com/u/1231635?v=3","gravatar_id":"","url":"https://api.github.com/users/phillipj","html_url":"https://github.com/phillipj","followers_url":"https://api.github.com/users/phillipj/followers","following_url":"https://api.github.com/users/phillipj/following{/other_user}","gists_url":"https://api.github.com/users/phillipj/gists{/gist_id}","starred_url":"https://api.github.com/users/phillipj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phillipj/subscriptions","organizations_url":"https://api.github.com/users/phillipj/orgs","repos_url":"https://api.github.com/users/phillipj/repos","events_url":"https://api.github.com/users/phillipj/events{/privacy}","received_events_url":"https://api.github.com/users/phillipj/received_events","type":"User","site_admin":false},"created_at":"2015-07-23T07:47:15Z","updated_at":"2015-07-23T07:47:15Z","body":"Great feedback @OverloadUT and thanks for the following up with what's needed for PIN auth to work.\r\n\r\nGoing further with your example:\r\n```js\r\nvar PlexAPI = require('plex-api');\r\nvar plexPinAuth = require('plex-api-pin-auth');\r\n\r\nvar client = new PlexAPI({\r\n    hostname: 'localhost',\r\n    authenticator: plexPinAuth\r\n});\r\n\r\n// would have to call .use() on an object, right?\r\n// or did you mean globally on PlexAPI?\r\nclient.use(plexPinAuth);\r\n\r\n// ... some time later when PIN auth is ready\r\nclient.find('/', ...);\r\n```\r\n\r\nWhat do you think about skipping the `.use(authenticator)` \"ceremony\" and adding an extra (optional) method on authenticators: `initialize(options)`? That method could be called as the last line in the PlexAPI constructor, providing authenticators with that instance's options if need.\r\n\r\nAre providing `options` enough or is the actual plex-api instance needed for PIN auth?"}}