Nirav Dabhi
Nirav Dabhi

Reputation: 343

Facebook status not updated. Error 403, authentication error, SocialAuthException in Android

I have created an Android application, in that the authorization with Facebook is done fine, but when I tap on the update status button it shows exception. It returns status code 403.

Code is:

if (providerName.equalsIgnoreCase("facebook") 
        {
            try 
            {
                adapter.updateStory(
                        "Hello SocialAuth Android" + System.currentTimeMillis(),
                        "AAA",
                        "BBB",
                        "CCC.",
                        "DDD", "EEE",
                        new MessageListener());
            }
            catch (UnsupportedEncodingException e) 
            {               
                e.printStackTrace();
            }
        }

Upvotes: 5

Views: 4291

Answers (3)

Sunny Garg
Sunny Garg

Reputation: 1073

Replace the socialauth-4.4.jar with below jar file url link. And check Facebook sharing will work.

Download jar file from

https://socialauth-android.googlecode.com/issues/attachment?aid=1880009000&name=test_social.jar&token=ABZ6GAeEabJhhI5PtmSHn7pA8pcsk6s_Zw%3A1415373843808

Upvotes: 0

Kevin Sandow
Kevin Sandow

Reputation: 4033

Looking through the SocialAuth Wiki I found a current bug matching your description:

https://code.google.com/p/socialauth-android/issues/detail?id=175

So you're not alone with your problem. You could provide any more information in their issue tracker to help and to indicate the severity of the problem.

But besides that I'm afraid you'll just have to wait - or consider fixing the bug in the otherwise open source library on your own.


You could also check whether the original Java implementation or the .Net port are experiencing the same problem; if not the code from those libraries might help to find a solution.

Upvotes: 4

gprathour
gprathour

Reputation: 15333

You are getting 403 Authentication Error that clearly means that your app is presently not authorized to publish on Facebook profile of the user.

There is some problem the way you are trying to use Facebook APIs. I would suggest you to the latest Facebook SDK for Android as some of the older methods may be deprecated. Let me tell you the approach for doing this right way. (I recently implemented latest Facebook SDK)

  • You need a permission

There are some specific permissions that you require to do some specific operations with Facebook SDK. For example, You need publish_actions permission if you want your app to post status on user's profile.

Check Out It says,

For example, the publish_actions permission lets you post to a person's Facebook Timeline.

  • How to get Permissions

You need to show the user a login button which will ask him to do login with his facebook account and notifying the user what your app may do with his Facebook profile. It will show the permissions. In your case you need to add a login button with publish_actions permission. Once the user accepts it, your app becomes authorized to post status.

Complete Tutorial is here for doing the login process of Facebook with permissions.

You will need to do the following,

LoginButton authButton = (LoginButton) view.findViewById(R.id.authButton);
authButton.setFragment(this);
authButton.setReadPermissions(Arrays.asList("user_likes", "user_status", "publish_actions"));
return view;

So you can see we are asking the user to give you the publish_actions permission. It is not mandatory to include user_likes or user_status permissions. You can remove them if you don't need them.

  • Next what after login

After the user logs in, you get an authentication token in your session with Facebook. So now you can use that to publish on user's profile.

  • How to post

Now there are many ways to publish posts or status on Facebook. The first one I would like to discuss is using the Graph API

Check this link for more details

Here is somewhat code, you can use to publish to facebook.

Session session = Session.getActiveSession();

new Request(
    session,
    "/me/feed",
    null,
    HttpMethod.POST,
        new Request.Callback() {
            public void onCompleted(Response response) {

            }
        }
).executeAsync();

or You can go through this tutorial also.

NOTE

You do also need to create developer account with facebook and add your app to its dashboard, generate an app_id and mention the same in your AndroidManifest.xml file.

More Info

Upvotes: 2

Related Questions