java - Post to facebook wall through spring social InsufficientPermissionException -


i trying make simple app spring social, app not public. trying achieve post wall or page administer.

trying ask facebook access manage_pages permission denied because said "you not need request these permissions because blog or cms integrated app admin. app admin, can access these permissions , post timeline or page admin. can provide access additional users adding them developers of app."

now in code. altered bit spring social showcase example. , case follows: 1) login facebook through app 2) trying number of pages administer 3) post wall.

for step 2 using code:

if (facebook.pageoperations().getaccounts() != null) {         system.out.println("size of acccounts is: " + facebook.pageoperations().getaccounts().size());     } 

the size of accounts 0. means although should able post pages administrator can not see them. correct?

for step 3 now:

facebook.feedoperations().updatestatus("i'm trying out spring social!");     facebook.feedoperations().post(new postdata("me").message("i'm trying out spring social!")         .link("http://www.springsource.org/spring-social", null, "spring social", "the spring social project", "spring social extension spring enable applications connect service providers."));     system.out.println("feed posted"); 

both of attempts fail following exception:

org.springframework.social.insufficientpermissionexception: insufficient permission operation.

could please?

it seems have not asked/granted permissions need during login. first thing need implement login , ensure sure include correct scope i.e. permission (manage_pages) during login. since requirements include publishing, include these permissions publish_pages and/or publish_actions depending on whether want publish page or yourself. e.g. if using js sdk, this:

 fb.login(function(response) {    // handle response  }, {scope: 'manage_pages, publish_pages, publish_actions'}); 

once this, on logging in, prompted if want grant these permissions. on granting, access token contain these permissions , able make call /me/accounts give list of pages admin , respective access tokens. this:

"data": [     {       "access_token": "caacedeose0cbaay...",       "category": "food/grocery",       "name": "page name",       "id": "1234567890",       "perms": [         "administer",         "edit_profile",         "basic_admin"       ]     },     ...     ] 

if want publish yourself, can continue using current user access token. else if want publish page, grab page access token response above , use make post request against page id.

and if creating app , not public, not need submit these permissions review provided admin or have role in app.

you might able find more context here.


Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -