如何使用android AccountManager在twitter中授权?
AccountManager am = AccountManager.get(this);
Account[] accts = am.getAccountsByType(TWITTER_ACCOUNT_TYPE);
if(accts.length > 0) {
Account acct = accts[0];
am.getAuthToken(acct, "com.twitter.android.oauth.token"/*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);
}
现在我得到了 com.twitter.android.oauth.token 和 com.twitter.android.oauth.token.secret 。但是下一步是什么?我如何使用它来授权?
我使用 scribe api,我试着像这样使用它:
service.signRequest(new Token(token, secret), request);
但它不起作用。我还尝试了另一种不起作用的方法。 有很多这样的问题:
https://dev.twitter.com/discussions/4875
https://groups.google.com/forum/?fromgroups#!topic/twitter-development-talk/1tWEx--5h9w%5B1-25%5D
http://osdir.com/ml/twitter4j/2011-06/msg00128.html
Android: How to Twitter oAuth Through Account Manager
Twitter Authentication through Android's AccountManager classes
Using account manager to get OAuth token
没有人给出具体的答案
最佳答案
Android 的 AccountManager 返回的 com.twitter.android.oauth.token
和 com.twitter.android.oauth.token.secret
凭据仅使用 Twitter 的官方 Consumer 进行身份验证 key 和 secret 。据我所知,它们实际上对第三方开发人员没有用。
关于 Twitter,我只想说它们就在那里,如果 Twitter 通过应用更新更改它们,那么如果没有该应用更新,它们就会破坏每个用户的 OAuth。
关于android - 如何使用android AccountManager在推特上授权?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11998788/