Home FB Graph API: Grabbing all mutual friends - (#200) You do not have sufficient permissions to perform this action
Reply: 0

FB Graph API: Grabbing all mutual friends - (#200) You do not have sufficient permissions to perform this action

user3332 Published in July 23, 2018, 1:15 pm

I am using AWS Lambda to ask for all mutual friends between current user and another user as stated here: https://developers.facebook.com/docs/graph-api/reference/user-context/all_mutual_friends/

I have looked through all the other stackoverflow answers and can't really find one close enough and have followed each of their answers to still get errors like these: Facebook Graph All Mutual Friends and "Requires a valid user is specified ..." error when using getCount

and my code looks like the below in AWS, note that I have used this node.js third-party sdk (https://github.com/node-facebook/facebook-node-sdk):

// Imports third-party fb graph api node.js sdk: https://github.com/node-facebook/facebook-node-sdk
const fbGraph = require('fb');

// Grabs app secret and app ID
const appSecret = process.env.APP_SECRET;
const appID = process.env.APP_ID;

// Uses user access token and grabs total count of all relevant mutual friends
exports.handler = (event, context, callback) => {
    // Grabs relevant details from request
    // const accessToken = event.accessToken;
    const friendUserID = event.friendUserID;

    fbGraph.api('oauth/access_token', {
        client_id: appID,
        client_secret: appSecret,
        grant_type: 'client_credentials'
    }, function (res) {
        if(!res || res.error) {
            console.log(!res ? 'error occurred' : res.error);

        let access_token = res.access_token;

        // Sets options for fb graph api to work
        fbGraph.options({accessToken: access_token, appId: appID, appSecret: appSecret, timeout: 12000});

        // Sets up fields and query string for request
        const friendUserIDQueryString = '/' + friendUserID; 
        const fields = { 
            fields: 'context.fields(all_mutual_friends.limit(10))' 

        // Sends api request to get all mutual friends
        fbGraph.api(friendUserIDQueryString, 'post', fields, function(response) {

            // Error handling
            if (response.error) {
                // Logs error
                context.done(null, { MutualFriendsTotalCountError: 'Error: not able to receive response' });

                // Returns error message
                return callback(new Error(`Mutual friends total count error: ${response.error}`));

            // Logs successful operation
            context.done(null, { MutualFriendsTotalCountSuccess: `Success: grabbed total mutual friend count for ${friendUserID}`});

            // Returns total count of mutual friends between current and other user as integer
            return callback(null, { total_count: response.context.all_mutual_friends.summary.total_count });

but my response is now this:

{ error: 
   { message: '(#200) You do not have sufficient permissions to perform this action',
     type: 'OAuthException',
     code: 200,

I don't really understand it, I've used my own access token on my IOS app I'm using this for, the application app token through OAuth, and also the other user ID who exists on my app and is the one thats specific for my app and other recommended solutions to no avail.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.321327 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO