Android的:如何给Twitter OAuth的客户经理 [英] Android: How to Twitter oAuth Through Account Manager

查看:123
本文介绍了Android的:如何给Twitter OAuth的客户经理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序,我想用在登录过程中的OAuth 的协议几个网站,如Twitter,Facebook和更多。我有关于Twitter OAuth的一些问题。

我以前的那些行访问令牌和秘密DATAS:

 的AccountManager AM = AccountManager.get(MyActivity.this);
帐户[] =帐户am.getAccountsByType(com.twitter.android.auth.login);如果(accounts.length大于0){
    账户ACCT =应收[0];
    am.getAuthToken(ACCT,com.twitter.android.oauth.token,空,MyActivity.this,新AccountManagerCallback<&捆绑GT;(){
        公共无效的run(AccountManagerFuture<群组>为arg0){
            //访问令牌
        }
    }, 空值);
}其他{
    Toast.makeText(getApplicationContext(),没有定义帐户,Toast.LENGTH_SHORT).show();
}

所以,我成功了。但我很好奇这些问题:


  • 请我需要的Twitter应用程序?

  • 如何将检查这些标记或我检查?我的意思是,我将如何到达用户的信息,如twitter_id?

任何信息将是巨大的。


解决方案

  

我是否需要任何Twitter应用程序?


是的,你将需要有一个Twitter帐户认证一个Twitter应用。对于这一点,去微博开发者来创建应用程序。


  

我将如何检查这些记号或做我要检查?我的意思是我将如何
  到达用户的信息,如twitter_id?


当您注册Twitter的开发者网站上的Twitter应用程序,Twitter将生成消费者密钥和应用程序的消费者的秘密。如果你愿意,你可以重新设置。都写在一个专门的部分您的应用程序。你的Twitter开发者账号> (你可以用你自己的Twitter凭证进行身份验证)> 我的应用&LT进入到本节code>并单击您的应用程序。

有关OAuth令牌和OAuth的秘密,微博开发者创建这最后的时候生成它们的应用程序的所有者。对于其他用户,你必须做一个OAuth认证流程得到他们(的OAuth)令牌和秘密。您还可以检索这个过程太,老板OAuth凭证。在该过程结束时,Twitter的API将会给你最终用户的令牌(OAuth凭证和OAuth秘密),Twitter的id和验证用户的网名(用户名)。有了这些信息,你就能得到你想要的所有信息。

In my application, I want to use oAuth protocol during login processes for several sites like Twitter, Facebook and more. I've some issues about Twitter oAuth.

I used those lines to access token and secret datas:

AccountManager am = AccountManager.get(MyActivity.this);
Account[] accounts = am.getAccountsByType("com.twitter.android.auth.login");

if(accounts.length > 0) {
    Account acct = accounts[0];
    am.getAuthToken(acct, "com.twitter.android.oauth.token", null, MyActivity.this, new AccountManagerCallback<Bundle>() {
        public void run(AccountManagerFuture<Bundle> arg0) {
            // Accessing token
        }
    }, null);               
} else {
    Toast.makeText(getApplicationContext(), "There is no defined account", Toast.LENGTH_SHORT).show();
}

So I succeed it. But I'm curious about these questions:

  • Do I need any Twitter application?
  • How will I check these tokens or do I have to check? I mean how will I reach users' information like twitter_id ?

Any information would be great.

解决方案

Do I need any Twitter application?

Yes, you will need a Twitter application for authentications with a Twitter account. For this, go to Twitter Developers to create your application.

How will I check these tokens or do I have to check? I mean how will I reach users' information like twitter_id ?

When you register your Twitter application on the Twitter developer website, Twitter will generate the consumer key and the consumer secret of your app. You can reset them if you want. They are written in a dedicated section for your app. You can access to this section by going to <your Twitter Developers account> (you can authenticate with your own Twitter credentials) > My Applications and clicking on your app.

For the OAuth token and the OAuth secret, Twitter Developers will generate them for the owner of the application when this last is created. For other users, you will have to do an OAuth Authentication Flow to get their (OAuth) token and secret. You can also retrieve the owner OAuth tokens with this process too. At the end of the process, the Twitter API will give you the final user's tokens (OAuth token and OAuth secret), the Twitter id and the screen name (username) of the authenticated user. With these informations, you will be able to get all the informations you want.

这篇关于Android的:如何给Twitter OAuth的客户经理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆