1
我建立使用Oauth1.0 Android上的Twitter客户端,我在中间Twitter客户端的Oauth Athentication为Android
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
OAuthConsumer consumer = new DefaultOAuthConsumer(
"CONSUMER_KEY",
"CONSUMER_CUSTOMER_KEY");
OAuthProvider provider = new DefaultOAuthProvider(
"https://api.twitter.com/oauth/request_token",
"https://api.twitter.com/oauth/access_token",
"https://api.twitter.com/oauth/authorize");
Toast.makeText(getApplicationContext(), "fetching request token", Toast.LENGTH_SHORT).show();
try
{
String authUrl = provider.retrieveRequestToken(consumer, OAuth.OUT_OF_BAND);
// Toast.makeText(getApplicationContext(), authUrl, Toast.LENGTH_SHORT).show();
String url = provider.retrieveRequestToken(consumer, OAuth.OUT_OF_BAND);
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)).setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_FROM_BACKGROUND);
this.startActivity(intent);
}
catch (OAuthMessageSignerException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (OAuthNotAuthorizedException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (OAuthExpectationFailedException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (OAuthCommunicationException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
现在我已经能与此授权的地方卡住了,但只要我输入我的用户名和密码,出现PIN码,不发生重定向!那么我想要的是显示用户的推文,而无需输入PIN码!我该怎么办 ?
由于提前
实际上回调网址的位置在哪里,以及究竟应该放入哪个网址! B'coz从用户的角度看,没有人会将密码输入到应用程序中 – Anuj
我该如何将URL传递回我的应用程序? – Anuj
请参阅[oAuth流](https://dev.twitter.com/docs/auth/oauth)使用回调URL和[此问题](http://stackoverflow.com/questions/2958701/launch-custom- android-application-from-android-browser)从浏览器中启动一个应用程序 – markdsievers