Android token and secret are different from the ones I generated on my twitter app account for my twitter user


#1

Hi,

I have created a twitter app, and was trying to use it in my android app.
I tried using the twitter4j package for the OAuth with the code below:

ConfigurationBuilder cnf= new ConfigurationBuilder(); 
cnf.setDebugEnabled(true);
        
mTwitter =new TwitterFactory(cnf.build()).getInstance();;
mTwitter.setOAuthConsumer(Constant.CONSUMER_KEY, Constant.CONSUMER_SECRET);

I am getting the token and secret by:

am.getAuthToken(acct, "com.twitter.android.oauth.token", null, mActivity, new AccountManagerCallback<Bundle>() {
                @Override
                public void run(AccountManagerFuture<Bundle> arg0) {
                    try {
                        Bundle b = arg0.getResult();
                        String token = b.getString(AccountManager.KEY_AUTHTOKEN);
                        String userName = b.getString(AccountManager.KEY_ACCOUNT_NAME);
                        handler.sendMessage(handler.obtainMessage(MSG_GOT_AUTH_TOKEN, token));
                    } catch (Exception e) { }}}, null); 

            am.getAuthToken(acct, "com.twitter.android.oauth.token.secret", null, mActivity, new AccountManagerCallback<Bundle>() {
                    @Override
                    public void run(AccountManagerFuture<Bundle> arg0) {
                        try {
                            Bundle b = arg0.getResult();
                            String secret = b.getString(AccountManager.KEY_AUTHTOKEN);
                            handler.sendMessage(handler.obtainMessage(MSG_GOT_AUTH_SECRET,secret));

                            }
                        catch (Exception e) {}}}, null); 

And for trying to send the tweet:

AccessToken accesstoken = new AccessToken(token,secret);
mTwitter.setOAuthAccessToken(accesstoken);

I am getting the token and the secret in the handler, but it fails since I am getting the error:

401:Authentication credentials (https://dev.twitter.com/docs/auth) were missing or incorrect. Ensure that you have set valid conumer key/secret, access token/secret, and the system clock in in sync.

I tried going into my app page on twitter developer page and created the access tokens on the Details page for my twitter account.
I tried entring it manually befor creating the access token, and it worked.

Do you know why Android is returning me other token and secret than the ones on the site? Should it be different?

Thanks,
Amir


#2

Did you find a solution for this ?


#3

Did you find a solution for this ?


#4

nooo


#5

Hi, I don’t really understand your code but I had a similar problem, that I have now solved. The thing was that I printed the Access Token and Access Token Secret which I was asking through the SINGPOST library. Then I compared those Strings with the ones in my dev.twitter account, of my app, and I noticed that the Access Token was the same, but the Access Token Secret wasn’t similar, it was the same that the Consumer Secret, so what I did in my code was to replace the method “getConsumerSecret()” with the method “getTokenSecret()” from the OAuthConsumer class.

I would be glad if this is of any help for you. Best wishes.


#6

I’ve got the same problem. Has someone solved it? Muy TokenSecret is different in my Twitter Dev page and in my Android application, but is not the equal to the Consumer secret… The AuthToken it is the same. Why is the account manager giving me a different AuthTokenSecret?


#7

Hi all, I’ve ran into the same problem as you guys. The access token and access token secret obtained through Android’s AccountManager doesn’t match the ones generated in my twitter dev account. Therefore, I get an error trying to verify my credentials when I bundle them with the consumer key and consumer secret in my dev account. I was just wondering if anybody has any updates on the problem. I feel like you should be able to do this especially since you can do this in iOS.


#8

I’m in the same situation, did you find the solution?


#9

hmm


#10

…///


#11

In this case we have to use the official consumer key, consumer secret sloved my problem.