Twitter Authentication through Android's AccountManager classes.
Posted
by
Robby Pond
on Stack Overflow
See other posts from Stack Overflow
or by Robby Pond
Published on 2011-02-01T22:39:22Z
Indexed on
2011/02/11
15:25 UTC
Read the original article
Hit count: 270
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);
}
© Stack Overflow or respective owner