CodexBloom - Programming Q&A Platform

how to to Get Facebook User's Friend List via Graph API v12.0 - Access Token guide

πŸ‘€ Views: 1348 πŸ’¬ Answers: 1 πŸ“… Created: 2025-06-17
facebook-graph-api oauth javascript JavaScript

I'm working on a personal project and I'm currently working on a feature that retrieves a user's friend list using the Facebook Graph API (v12.0), but I'm hitting a wall with access tokens. I followed the official documentation and requested the `user_friends` permission during the OAuth flow. However, the response I'm getting is pretty baffling. When I make the API call to `/me/friends`, I keep receiving the behavior message: `(#200) Permissions behavior: User does not have granted permission for user_friends`. Here's a snippet of the code I'm using to fetch the friend list: ```javascript const fetchFriends = async (accessToken) => { const response = await fetch('https://graph.facebook.com/v12.0/me/friends?access_token=' + accessToken); const data = await response.json(); console.log(data); }; ``` I have also checked the token using the Facebook Debugger Tool to ensure it includes the `user_friends` permission, and it appears to be valid. I’ve tried generating a new access token multiple times, ensuring that my app is in development mode, and that the user I’m testing with has granted access. I also verified that the friends I’m trying to access have the app installed. Still, I encounter the same behavior. Is there a specific requirement or a setting I might have overlooked that’s preventing me from accessing the friend list? Any insights would be greatly appreciated! I'm working with Javascript in a Docker container on Windows 11. I'd love to hear your thoughts on this.