Twitter Login not working in Nougat Devices using twitter core


#1

Twitter login using twitter core is not working on Android Nougat devices. While the same code works for Android Marshmallow devices. Nougat device, doesn’t have twitter app, and it doesn’t even open webview for the same, while in non-nougat devices, it falls back to webview if app is not installed in the phone.

It always gives authorization error in nougat devices with status code 403 and 401.

This is my activity code for login

 @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        twitterCore=TwitterCore.getInstance();
        loginButton = (TwitterLoginButton) findViewById(R.id.login_button);
        loginButton.setCallback(new Callback<TwitterSession>() {
            @Override
            public void success(Result<TwitterSession> result) {

                // Do something with result, which provides a TwitterSession for making API calls
            }

            @Override
            public void failure(TwitterException exception) {
                Log.d("failure: ",exception.getMessage());
                // Do something on failure
            }
        });
    }

I have initialized twitter config in the application class.

public class MyApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        TwitterConfig config = new TwitterConfig.Builder(this)
                .logger(new DefaultLogger(Log.DEBUG))
                .twitterAuthConfig(new TwitterAuthConfig("xxxxxxxxxx", "xxxxxxxxxxxx"))
                .debug(true)
                .build();
        Twitter.initialize(config);

    }
}