{"action":"created","issue":{"url":"https://api.github.com/repos/DaftMonk/generator-angular-fullstack/issues/1028","labels_url":"https://api.github.com/repos/DaftMonk/generator-angular-fullstack/issues/1028/labels{/name}","comments_url":"https://api.github.com/repos/DaftMonk/generator-angular-fullstack/issues/1028/comments","events_url":"https://api.github.com/repos/DaftMonk/generator-angular-fullstack/issues/1028/events","html_url":"https://github.com/DaftMonk/generator-angular-fullstack/issues/1028","id":91639151,"number":1028,"title":"Can't get access token in req from passport.js","user":{"login":"dvirhazout","id":8232263,"avatar_url":"https://avatars.githubusercontent.com/u/8232263?v=3","gravatar_id":"","url":"https://api.github.com/users/dvirhazout","html_url":"https://github.com/dvirhazout","followers_url":"https://api.github.com/users/dvirhazout/followers","following_url":"https://api.github.com/users/dvirhazout/following{/other_user}","gists_url":"https://api.github.com/users/dvirhazout/gists{/gist_id}","starred_url":"https://api.github.com/users/dvirhazout/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dvirhazout/subscriptions","organizations_url":"https://api.github.com/users/dvirhazout/orgs","repos_url":"https://api.github.com/users/dvirhazout/repos","events_url":"https://api.github.com/users/dvirhazout/events{/privacy}","received_events_url":"https://api.github.com/users/dvirhazout/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-06-28T20:57:08Z","updated_at":"2015-07-05T07:45:12Z","closed_at":null,"body":"I'm trying to achieve a multi-social-profiles account. currently just facebook and local.\r\nI can't get the req.user \\  object in passport.js\r\n\r\nhere're some peaces of code i'm using:\r\npassport.js:\r\n```javascript\r\n  passport.use(new FacebookStrategy({\r\n      clientID: config.facebook.clientID,\r\n      clientSecret: config.facebook.clientSecret,\r\n      callbackURL: config.facebook.callbackURL,\r\n      passReqToCallback: true\r\n    },\r\n    function(req, accessToken, refreshToken, profile, done) {\r\n```\r\n\r\nauth.service:\r\n```javascript\r\nfunction appendUser() {\r\n  return compose()\r\n    .use(function(req, res, next) {\r\n      \r\n      if(req.query && req.query.hasOwnProperty('access_token')) {\r\n        req.headers.authorization = 'Bearer ' + req.query.access_token;\r\n      }\r\n      validateJwt(req, res, next);\r\n    })\r\n    .use(function(req, res, next) {\r\n      User.findById(req.user._id, function (err, user) {\r\n        if (err) return next(err);\r\n        if (!user) return next(err);\r\n\r\n        req.user = user;\r\n        next();\r\n      });\r\n    });\r\n}\r\n```\r\n\r\nauth/index.js\r\n```javascript\r\nrouter\r\n  .get('/', auth.appendUser(), passport.authorize('facebook', { scope : 'email' }))\r\n\r\n  .get('/callback', auth.appendUser(), passport.authorize('facebook', {\r\n\t\tsuccessRedirect : '/settings',\r\n\t\tfailureRedirect : '/'\r\n\t}));\r\n```\r\n\r\nI'm a little lost with this one. struggeling with it for couple days.\r\nWhat am I missing?"},"comment":{"url":"https://api.github.com/repos/DaftMonk/generator-angular-fullstack/issues/comments/118593733","html_url":"https://github.com/DaftMonk/generator-angular-fullstack/issues/1028#issuecomment-118593733","issue_url":"https://api.github.com/repos/DaftMonk/generator-angular-fullstack/issues/1028","id":118593733,"user":{"login":"kingcody","id":2544108,"avatar_url":"https://avatars.githubusercontent.com/u/2544108?v=3","gravatar_id":"","url":"https://api.github.com/users/kingcody","html_url":"https://github.com/kingcody","followers_url":"https://api.github.com/users/kingcody/followers","following_url":"https://api.github.com/users/kingcody/following{/other_user}","gists_url":"https://api.github.com/users/kingcody/gists{/gist_id}","starred_url":"https://api.github.com/users/kingcody/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kingcody/subscriptions","organizations_url":"https://api.github.com/users/kingcody/orgs","repos_url":"https://api.github.com/users/kingcody/repos","events_url":"https://api.github.com/users/kingcody/events{/privacy}","received_events_url":"https://api.github.com/users/kingcody/received_events","type":"User","site_admin":false},"created_at":"2015-07-05T07:45:12Z","updated_at":"2015-07-05T07:45:12Z","body":"@simonbogarde simple answer is because only routes that have been authenticated using `auth.isAuthenticated()` or similar will have the `user` object attached. Your Google auth route is open."}}