Question

I am working on a twitter based app and am trying to incorporate Android's built-in Account support for Twitter. The following code works to popup the confirmation dialog for my app to access twitter but I am unsure of what to pass in as the authenticationType. Any help would be appreciated. I've googled all over the place and can't seem to find the correct answer. It goes in place of "oauth" below.

AccountManager am = AccountManager.get(this);
Account[] accts = am.getAccountsByType(TWITTER_ACCOUNT_TYPE);
if(accts.length > 0) {
    Account acct = accts[0];
    am.getAuthToken(acct, "oauth"/*what goes here*/, null, this, new AccountManagerCallback<Bundle>() {

    @Override
    public void run(AccountManagerFuture<Bundle> arg0) {
        try {
                     Bundle b = arg0.getResult();  
                     Log.e("TrendDroid", "THIS AUTHTOKEN: " + b.getString(AccountManager.KEY_AUTHTOKEN));  
                } catch (Exception e) {  
                     Log.e("TrendDroid", "EXCEPTION@AUTHTOKEN");  
                }  
    }}, null);
}
Was it helpful?

Solution

If you want OAuth you should use those ones :

  • com.twitter.android.oauth.token
  • com.twitter.android.oauth.token.secret

If you want the user's password then you can write your own authenticator. The official Twitter application does not store the password. The password is used only once to get those two tokens.

OTHER TIPS

from AccountManager docs:

Some authenticators have auth token types, whose value is authenticator-dependent. Some services use different token types to access different functionality -- for example, Google uses different auth tokens to access Gmail and Google Calendar for the same account.

I think, it is not very important. You should really ask the developer of twitter authenticator. Or write your own.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top