1
votes

i am using twitter4j and have registered myapp on https://dev.twitter.com/apps/new and got consumer key and secret. i am using folowing code

private static Twitter twitter;
    private static RequestToken requestToken;
ConfigurationBuilder builder = new ConfigurationBuilder();
            builder.setOAuthConsumerKey(TWITTER_CONSUMER_KEY);
            builder.setOAuthConsumerSecret(TWITTER_CONSUMER_SECRET);
            Configuration configuration = builder.build();

            TwitterFactory factory = new TwitterFactory(configuration);
            twitter = factory.getInstance();

            try {
                requestToken = twitter.getOAuthRequestToken(TWITTER_CALLBACK_URL);
                this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(requestToken.getAuthenticationURL())));
            }

this open a a page where i enter username and password of twitter account this works succefully. but ow i want to give username and password programatically to avoid opening that page

1

1 Answers

1
votes

The purpose of OAuth is to give (limited) permissions to applications without passing information about credentials (ID and password) to applications. Therefore, what you want to do conflicts with OAuth. To pass credentials to the input fields of Twitter's auth page programatically, nasty hack would be required. Twitter4J and other Twitter OAuth libraries won't support such a use case.