The user hasn't authorized the application to perform this action

25,008

Solution 1

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

You will want to ask for manage_pages and publish_stream. Once the admin of the page authenticates, query me/accounts and grab the page's access token from that list. Using that page's access token, then you can post to me/feed.

Solution 2

simple, u just need to ask permissions..that's it..

String[] permissions = { "offline_access", "publish_stream", "user_photos", "publish_checkins","photo_upload" };
mFacebook.authorize(MainActivity.this, permissions,
            new LoginDialogListener());
Share:
25,008
Mokhlisse Badre
Author by

Mokhlisse Badre

Updated on July 15, 2022

Comments

  • Mokhlisse Badre
    Mokhlisse Badre almost 2 years

    I am developing a simple java program to post automatically (articles) to my facebook fun page. I have created an app and have got an 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 fun 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 give my app authorization to post to my fun page ? thanks in advance

    following recommendation of

  • Mokhlisse Badre
    Mokhlisse Badre over 12 years
    I got a user access_token for page administrator using url : facebook.com/dialog/oauth/…, then the post goes to page wall. But still have problem : sent post is "as administrator" not "as page" so it doesn't appear on people who likes my fun page, it appears on "Everyone (Most Recent)"
  • Mokhlisse Badre
    Mokhlisse Badre over 12 years
    I got access_token after admin authenticate application, but the message is posted as "admin" not "as page", this is important to show updates to people that likes my page. Thanks.
  • DMCS
    DMCS over 12 years
    Hmmm, below you say just the opposite is what you're looking for "But still have problem : sent post is "as administrator" not "as page"" So which is it? Posting it as a page to the page, or as the admin to the page?
  • Mokhlisse Badre
    Mokhlisse Badre over 12 years
    should use "page access token" as descr ibe in facebook doc page developers.facebook.com/docs/reference/api/page instead of user (admin) access token. Thanks Juicy Scripter
  • SharpXxx
    SharpXxx over 12 years
    @MokhlisseBadre, welcome to Stack Overflow. Don't forget to accept answers ;)
  • Mokhlisse Badre
    Mokhlisse Badre over 12 years
    problem solved. I was able to post to page as page not as admin. I put an explaining note above. thx.
  • DMCS
    DMCS over 12 years
    yes, this is what I described in my answer. How to post to the page as the page. :) This question is asked about once a day on average on SO. :O
  • Krishnakant Dalal
    Krishnakant Dalal almost 12 years
    It's worked in my case too but Where to place this code. And how to know that user already permitted this or not.
  • W00di
    W00di almost 12 years
    @KrishnakantDalal i did not get "where to place this code" . And Facebook UI will ask the permissions to the user when he first tries to login using Facebook. And it asks only once.
  • ssaltman
    ssaltman over 10 years
    The key here is the "publish_stream" and "manage_pages" perms. With only "manage_pages" you'll get a bounce.