如何在twitter中使用android AccountManager进行授权?
作者:互联网
如何在twitter中使用android AccountManager进行授权?
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的官方消费者密钥和密钥进行身份验证. AFAIK他们对第三方开发人员实际上并没有用.
关于Twitter,我只是说他们在那里,如果Twitter通过应用程序更新改变它们,他们将为没有该应用程序更新的每个用户打破OAuth.
标签:android,twitter,scribe,accountmanager,android-account 来源: https://codeday.me/bug/20190709/1414113.html