Reputation: 1256
I have web application where I use Facebook oauth. User authentication works fine. and in javascript when I call FB.getUserID()
I get correct identification. But when I try do this I get empty array:
FB.api('/me/albums', function (response) {
console.log(response.data);
console.log(FB.getUserID());
});
What I do wrong?
Upvotes: 0
Views: 139
Reputation: 3674
In order to retrieve the albums created by that user, you must provide user_photos permission to your access token.
Have a look at the this documentation on albums. It clearly says under permission that your Access Token must have the user_photos permission to retrieve the the albums. Without this specific permission, it'll return an empty object.
Now, in order to provide one or more additional permissions, call FB.login with an option object, and set the scope parameter with a comma-separated list of the permissions you wish to request from the user.
FB.login(function(response) {
// handle the response
}, {scope: 'user_photos,friends_photos'});
Reference: Javascript FB.login doc
Upvotes: 1