{"action":"created","issue":{"url":"https://api.github.com/repos/request/request/issues/1360","labels_url":"https://api.github.com/repos/request/request/issues/1360/labels{/name}","comments_url":"https://api.github.com/repos/request/request/issues/1360/comments","events_url":"https://api.github.com/repos/request/request/issues/1360/events","html_url":"https://github.com/request/request/pull/1360","id":54676441,"number":1360,"title":"Refactor basic, bearer, digest auth logic into separate class","user":{"login":"simov","id":1694112,"avatar_url":"https://avatars.githubusercontent.com/u/1694112?v=3","gravatar_id":"","url":"https://api.github.com/users/simov","html_url":"https://github.com/simov","followers_url":"https://api.github.com/users/simov/followers","following_url":"https://api.github.com/users/simov/following{/other_user}","gists_url":"https://api.github.com/users/simov/gists{/gist_id}","starred_url":"https://api.github.com/users/simov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simov/subscriptions","organizations_url":"https://api.github.com/users/simov/orgs","repos_url":"https://api.github.com/users/simov/repos","events_url":"https://api.github.com/users/simov/events{/privacy}","received_events_url":"https://api.github.com/users/simov/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-01-17T21:41:32Z","updated_at":"2015-01-18T20:42:04Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/request/request/pulls/1360","html_url":"https://github.com/request/request/pull/1360","diff_url":"https://github.com/request/request/pull/1360.diff","patch_url":"https://github.com/request/request/pull/1360.patch"},"body":"**WIP**\r\n\r\nI moved the `auth` method logic into separate file. The `auth` method is split into two methods `basic` and `bearer`. Also I moved `_digest` and the part of the code in `onRequestResponse` related to these 3 methods.\r\n\r\nThe reasons to move exactly these functions is as follows: all private flags `_hasAuth`, ` _sentAuth` and private variables `_bearer`,` _user`, `_pass` are local for the `Auth` class. That way `request` now knows only about only 3 distinct methods `_auth.basic`, `_auth.bearer` and `_auth.response` versus 6 variables `_hasAuth`, `_sentAuth`, `_bearer`, `_user`, `_pass` and `_digest`\r\n\r\nThe `Auth` class keeps a pointer to the `request` instance, but only use it to modify the headers, as well as reading some values (as I said private variables related to the `Auth` class are not set in `request`)\r\n\r\nOther than that the code is mostly copy/pasted without changes, it certainly can be improved but I wanted to make this PR as short as possible. Also the `debug` call is currently commented out.\r\n\r\nPing @nylen @seanstrom @FredKSchott "},"comment":{"url":"https://api.github.com/repos/request/request/issues/comments/70424903","html_url":"https://github.com/request/request/pull/1360#issuecomment-70424903","issue_url":"https://api.github.com/repos/request/request/issues/1360","id":70424903,"user":{"login":"nylen","id":227022,"avatar_url":"https://avatars.githubusercontent.com/u/227022?v=3","gravatar_id":"","url":"https://api.github.com/users/nylen","html_url":"https://github.com/nylen","followers_url":"https://api.github.com/users/nylen/followers","following_url":"https://api.github.com/users/nylen/following{/other_user}","gists_url":"https://api.github.com/users/nylen/gists{/gist_id}","starred_url":"https://api.github.com/users/nylen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nylen/subscriptions","organizations_url":"https://api.github.com/users/nylen/orgs","repos_url":"https://api.github.com/users/nylen/repos","events_url":"https://api.github.com/users/nylen/events{/privacy}","received_events_url":"https://api.github.com/users/nylen/received_events","type":"User","site_admin":false},"created_at":"2015-01-18T20:42:04Z","updated_at":"2015-01-18T20:42:04Z","body":"This is excellent stuff @simov.\r\n\r\nHow about getting rid of any underscores in `self._someValue`, can't anything on the `Auth` object be a \"public\" property?\r\n\r\n---\r\n\r\nI'm not saying that we should do the following now.  But, given that we want to move towards a composable API, what would it take to get there for this PR?  I'm thinking that inside `request.js`, the code would look something like this:\r\n\r\n```js\r\nrequire('./lib/auth').extend(Request)\r\n```\r\n\r\nWhat hooks would be necessary in `request` to make this work?  Then, later on, we'd move `request-auth` into its own module and add some machinery for users to disable this default auth library.\r\n\r\nOne issue I foresee - I'm sure there are others:  say an app has two different use cases for `request` where one needs to have the default auth provider and the other needs some custom thing, how do you accomplish this?\r\n\r\n"}}