【问题标题】:How to authorize in twitter using android AccountManager?如何使用 android AccountManager 在 twitter 中进行授权?
【发布时间】:2012-08-17 01:45:13
【问题描述】:

如何使用 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.tokencom.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

没有人给出具体答案

【问题讨论】:

  • 我不建议您继续使用您的应用程序(抱歉),因为 twitter 限制了它的访问。阅读此内容:Twitter 想要阻止您使用并非由 Twitter 开发的 Twitter 应用程序 gizmodo.com/5935517
  • 其实我只需要用户个人资料数据..
  • 您能说得更具体些吗?什么不起作用?你有错误吗?什么是堆栈跟踪?您是否尝试过在调试模式下使用scribe?在您提供的代码示例中,tokensecret 的值是多少?
  • @Pablo,我认为问题不在于抄写员...我有 "THIS AUTHTOKEN: " + b.getString(AccountManager.KEY_AUTHTOKEN) 其中 b.getString(AccountManager.KEY_AUTHTOKEN) 是 android 客户经理获得的令牌,我不知道如何使用它与 scribe 对 twitter 进行授权
  • 问题可能是这样的:How to authorize twitter using AccountManager and scribe...

标签: android twitter accountmanager scribe android-account


【解决方案1】:

Android 的 AccountManager 返回的 com.twitter.android.oauth.tokencom.twitter.android.oauth.token.secret 凭据仅使用 Twitter 的官方 Consumer Key 和 Secret 进行身份验证。 AFAIK 它们实际上对第三方开发人员没有用。

关于 Twitter,我只想说它们已经存在,如果 Twitter 通过应用更新更改它们,他们会在没有应用更新的情况下破坏每个用户的 OAuth。

【讨论】:

    猜你喜欢
    • 2013-04-22
    • 2011-12-14
    • 2012-11-30
    • 2013-03-14
    • 1970-01-01
    • 2015-03-16
    • 2011-09-14
    • 2018-04-23
    相关资源
    最近更新 更多