Reputation: 29497
I've been building a project using Twitter4J, the problem is that don't matter where I try to run this code it always use my Twitter account to authenticate and worst: It doesn't authenticate. When I open the script it has already authenticated with my account without asking me to accept or not. This is the code I'm using:
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true)
.setOAuthConsumerKey("********")
.setOAuthConsumerSecret("****************************************")
.setOAuthAccessToken("***********************************************")
.setOAuthAccessTokenSecret("***************************************");
TwitterFactory tf = new TwitterFactory(cb.build());
Twitter twitter = tf.getInstance();
What I'm doing wrong and how to correct it?
Upvotes: 0
Views: 994
Reputation: 21
the problem is that don't matter where I try to run this code it always use my Twitter account to authenticate
You must be using oAuth to get authenticated from twitter.. In oAuth, if you register your app for account_A, then you wont be able to login via that application using account_B.. You should request Twitter API team to provide your application access of xAuth.. Using xAuth, You can use any username/password to login to twitter using your own application..
Let me know please in case you've any questions..
-QamarZ
Upvotes: 2
Reputation: 35961
Are you using this code to authentication only or for making other api calls?
You don't need to set access token and token secret, if you need to authenticate an new user. It have to use only consumer's key/secret there. (Then prepare new callback url, redirect user, etc, etc)
Access token is used when you are requesting other data from twitter api, for specified user (connected to this accestoken).
And also, note that twitter authentication gives you credentials of currently logged in user. I mean user that already logged into twitter. And also it ask him only once - when he tries to authenticate first time, at second time it will reuse it.
Upvotes: 1