FB.api('/1354376857/groups', function(response){
Data = response.name;
alert(Data);
if (response.error) {
alert(response.error.message);
}
});
The outputted error message reads: "An access token is required to request this resource" and Data content is undefined for my Facebook app. The user is successfully logged in and the "user_groups" permission has been approved by the user.
I was under the impression that FB.api automatically sets the access token. Any thoughts on why this error is occurring?
FB.api('/1354376857/groups', function(response){
Data = response.name;
alert(Data);
if (response.error) {
alert(response.error.message);
}
});
The outputted error message reads: "An access token is required to request this resource" and Data content is undefined for my Facebook app. The user is successfully logged in and the "user_groups" permission has been approved by the user.
I was under the impression that FB.api automatically sets the access token. Any thoughts on why this error is occurring?
Share Improve this question edited Aug 15, 2015 at 2:34 Pang 10.1k146 gold badges86 silver badges124 bronze badges asked Dec 10, 2013 at 3:36 user3085287user3085287 231 silver badge3 bronze badges 2- Use access token along with the request stackoverflow./questions/4758770/… – Surabhil Sergy Commented Dec 10, 2013 at 3:43
- Thank you Surabhil.. You're guidance was essential to solving the problem. – user3085287 Commented Dec 10, 2013 at 17:11
1 Answer
Reset to default 7Change your code to this
var token = "YOUR_TOKEN";
FB.api('/1354376857/groups', function(response){
Data = response.name;
alert(Data);
if (response.error) {
alert(response.error.message);
}
}, {access_token: token});
You must pass your access token every time you do a request to the facebook api.