Error 401 android rest api

android
oauth

#1

I got the successful login, and get basic detail and also tweet list, but Getting 401 error , while getting the follower list in Android using rest Api , its saying 401 error.


#2

Can you be more specific? Are you using Twitter Kit for Android? Can you share any code and explain the point at which you are seeing the 401 error?


#3

yes , i am using twitter android kit

here is the twitter authentication code, that we got success nad after success i am calling initFollower() method

 login_button.setCallback(new Callback<TwitterSession>() {
            @Override
            public void success(Result<TwitterSession> result) {
                TwitterSession session = TwitterCore.getInstance().getSessionManager().getActiveSession();
                TwitterAuthToken authToken = session.getAuthToken();

           ` **initFollower(result.data.getUserId(),result.data);**`
                
            }

            @Override
            public void failure(TwitterException exception) {
            }
        });

void initFollower(long id,TwitterSession session) {
        MyTwitterApiClient client=new MyTwitterApiClient(session);
        CustomService service=client.getCustomService();
        Call<List<User>> data=service.show(id,null,null,null,false,null);
        data.enqueue(new Callback<List<User>>() {
            @Override
            public void success(Result<List<User>> result) {
                Log.e("",""+result);

            }

            @Override
            public void failure(TwitterException exception) {
                exception.printStackTrace();

            }
        });


    }

#4

here is custom class

public class MyTwitterApiClient extends TwitterApiClient {

    public MyTwitterApiClient(TwitterSession session) {
        super(session);
    }

    public CustomService getCustomService() {
        return getService(CustomService.class);
    }
}

here is interface

public interface CustomService {
    @GET("/1.1/followers/list.json?"+"cursor=-1&screen_name=twitterdev&skip_status=true&include_user_entities=false")
    Call<List<User>> show(@Query("user_id") Long userId,
                          @Query("screen_name") String screenName,
                          @Query("cursor") String cursor,
                          @Query("count") String count,
                          @Query("skip_status") boolean skip_status,
                          @Query("include_user_entities") Boolean include_user_entities);
}

#5

Can you please provide quick solution , because its urgent please


#6

(moved to the Twitter Kit category for additional attention / investigation)

Unfortunately we’re not able to commit to specific timeframes to address individual questions, but someone will try to take a look when they have time. Thanks.