Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8826265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:05:40+00:00 2026-06-14T07:05:40+00:00

Probably obvious and simple. I have an application that should access a Facebook users

  • 0

Probably obvious and simple. I have an application that should access a Facebook users friends information. After a user have been authenticated using PassportJS and my application receives the accesstoken how do I fetch the users friends information? Or any protected information that is? And what is the scope parameter for users friends access?

EDIT:
Just want to mention that the original question wasn’t really answered, but the answer was enough to make me continue with my investigations.

My solution was to use PassportJS for managing the login flow, and when I receive the accessToken I use it for my Facebook Graph API calls, which are extremely easy to do. I will do some rework on my module for this and publish it on GitHub to be used as is.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T07:05:41+00:00Added an answer on June 14, 2026 at 7:05 am

    In order to modify the scope, you do this when you setup your route for the Facebook Strategy.

    For example, if I want the user’s email to be part of my scope, mine would look like the following:

    app.get('/auth/facebook', passport.authenticate('facebook',  { scope: 'email' }));
    app.get('/auth/facebook/callback',
      passport.authenticate('facebook', { successRedirect: '/',
                                          failureRedirect: '/' }));
    

    I am saving my information to MongoDB with Mongoose, but you can just as easily stick their friends inside the req.user. Here is an example of how I map my Facebook user’s data:

    passport.use(new FacebookStrategy({
        clientID: Common.conf.fb.appId,
        clientSecret: Common.conf.fb.appSecret,
        callbackURL: Common.conf.site_url + "/auth/facebook/callback"
      },
      function(accessToken, refreshToken, profile, done) {
        Model.User.findOne({uid: profile.id}, function(err, user) {
          if (err) { return done(err); }
          if (user) { done(null, user); } else {
            var user_data = {
              provider:   profile.provider
              , alias:  profile.username
              , email:      profile.emails[0].value
              , uid:      profile.id
              , created:  new Date().getTime()
              , name: {
                first:  profile.name.givenName
                , last: profile.name.familyName
              }
              , alerts: {
                email:      true
                , mobile:   false
                , features: true
              }
            };
            new Model.User(user_data).save(function(err, user) {
              if(err) { throw err; }
              done(null, user);
            });
          }
        });
      }
    ));
    

    Sometimes it is helpful to put a console.log(profile) like so:

       function(accessToken, refreshToken, profile, done) {
            console.log(profile);
    

    in order to help you see the raw output of what the Facebook API is giving you and to check that your custom scope variables exist.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is probably a really stupid/simple question with such an obvious answer that it
Apologies for asking what's probably a very obvious question, I've been banging my head
This is probably really obvious and simple - but it isn't to me with
I ask trepidatiously as there is probably a simple obvious solution somewhere, but given
This is probably something very obvious, but I have a new to Qt and
This is probably really simple, and the answer is probably really obvious, but I'm
I'm building a simple solid modeling application. Users need to be able to manipulate
This is probably a very simple answer, but I'm not seeing an obvious solution
I have a very simple hover function that appears to work fine in everything
This is probably a simple mistake. I have a nodejs server running socket.io, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.