403 Forbidden error when using REST Apis


I am using a guest auth to fetch the last tweet of a user in an android app. The problem that i am facing is that it seems to work initially but after some time, i keep getting 403 Forbidden code in the REST api call.

I am using the following code:

        Fabric.with(this, new Twitter(authConfig));

        TwitterCore.getInstance().logInGuest(new Callback() {
            public void success(Result result) {
                final AppSession guestAppSession = (AppSession) result.data;

                TwitterApiClient twitterApiClient = TwitterCore.getInstance().getApiClient();
                twitterApiClient.getStatusesService().userTimeline(null, screen_name, 1, null, null, true, false, false, true, new Callback<List<Tweet>>() {
                    public void success(Result<List<Tweet>> listResult) {
//                        Toast.makeText(MainActivity.this, "Success", Toast.LENGTH_LONG).show();
                        List<Tweet> tweets = listResult.data;
                        int i = tweets.size();
                        int count = 0;
                        while (count < i) {
                            Toast.makeText(MainActivity.this, tweets.get(count).text, Toast.LENGTH_LONG).show();

                    public void failure(TwitterException e) {
                        Toast.makeText(MainActivity.this, e.toString(), Toast.LENGTH_LONG).show();


            public void failure(TwitterException exception) {
                // unable to get an AppSession with guest auth

Can somebody please help me out.

Warm Regards,


Maybe trying to pass the guestAppSession variable as parameter of getApiClient().

TwitterApiClient twitterApiClient = TwitterCore.getInstance().getApiClient(guestAppSession);


@jahertor90 yup…that’s exactly what i did in the morning after posting the question…realized it a tad too late :frowning:
didn’t have any problem since then… :smile:
thanks anyways…