The user did not allow the application to perform this action.

I am developing a simple java program to automatically publish (articles) on my facebook funbook page. I created the application and got access_token using url: https://graph.facebook.com/oauth/access_token?grant_type=client_credentials&client_id=APP_ID&client_secret=CLIENR_SECRET . I use this java code to post to the page wall:

String url = "https://graph.facebook.com/" + PAGE_ID + "/feed" List<NameValuePair> nvps = new ArrayList<NameValuePair>(); nvps.add(new BasicNameValuePair("access_token", accessToken)); nvps.add(new BasicNameValuePair("message", item.getTitle())); HttpClient client = new DefaultHttpClient(params); HttpPost httpost = new HttpPost(url); httpost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8)); HttpResponse response = client.execute(httpost); HttpEntity entity = response.getEntity(); 

I got this error:

 { "error": { "message": "(#200) The user hasn't authorized the application to perform this action", "type": "OAuthException" } } 

How can I allow authorization of my application to be sent to my interesting page? thank you in advance

next recommendation

+4
source share
4 answers

Wow, I see the same question asked at least once a day.

You want to request manage_pages and publish_stream . After authorization by the page administrator, request me/accounts and take the access token from the list. Using the page access token, you can send a message to me/feed .

+15
source

just, you just need to ask permission .. what is it ..

 String[] permissions = { "offline_access", "publish_stream", "user_photos", "publish_checkins","photo_upload" }; mFacebook.authorize(MainActivity.this, permissions, new LoginDialogListener()); 
+2
source

You are using the access_token application, while you must use access_token for the user or page.

  • The access_token user access_token present in signed_request (in the cookie or passed to the application canvas).
  • The access_token page is available in the accounts connecting the user after the user has granted you manage_pages permission for your application.

Update:
To publish as an administrator, you need the user access_token.
To publish on the page, you need the access_token page

0
source

Facebook changed the permission of publish_stream to publish_actions . Therefore, you need to apply publish_actions and manage_pages .

0
source

Source: https://habr.com/ru/post/1389130/


All Articles