I see you are using "new DefaultOAuthProvider". I had to change that to "new CommonsHttpOAuthProvider" in an example very similar to yours when I switched over to using HTTPS, which I note you are as well. Details here: http://code.google.com/p/agirardello/issues/detail?id=1
On Nov 11, 2:23 am, Babita kumari <[email protected]> wrote: > Ya Bibek , > > I am getting following error : > > 11-10 10:48:46.348: ERROR/OAUTH(409): Communication with the service > provider failed: Received authentication challenge is null > > I have added Twitter4J and signpost as library and I have registered as > client type on Twitter . And my code is following: > > public class TwApp extends Activity > { > private static final String APP ="OAUTH"; > > private Twitter twitter; > TextView tweettx; > Button login; > > private OAuthProvider provider; > > private CommonsHttpOAuthConsumer consumer; > private static final String CONSUMER_KEY = " consumer key... "; > private static final String CONSUMER_SECRET = "consumerSecret key.."; > > String verifier ; > > /** Called when the activity is first created. */ > @Override > public void onCreate(Bundle savedInstanceState) > { > super.onCreate(savedInstanceState); > setContentView(R.layout.main); > > tweettx = (TextView)findViewById(R.id.tweet); > > login = (Button) findViewById(R.id.main_loin_button); > > login.setOnClickListener(new OnClickListener() > { > public void onClick(View v) > { > askOAuth(); > } > }); > } > > private void askOAuth() > { > try > { > consumer = new CommonsHttpOAuthConsumer(CONSUMER_KEY, > CONSUMER_SECRET ); > provider = new > DefaultOAuthProvider("https://api.twitter.com/oauth/request_token", > > "https://api.twitter.com/oauth/access_token", > > "https://api.twitter.com/oauth/authorize"); > > String authUrl = provider.retrieveRequestToken(consumer, > OAuth.OUT_OF_BAND); > System.out.println("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&" + > authUrl); > > Toast.makeText(this, "Please authorize this app!", > Toast.LENGTH_LONG).show(); > > this.startActivity(new Intent(Intent.ACTION_VIEW, > Uri.parse(authUrl))); > > } catch (Exception e) > { > System.out.println("&&&&&&&&&&&&&&&&ERROR_____" + e); > Log.e(APP, e.getMessage()); > Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show(); > } > } > > @Override > protected void onNewIntent(Intent intent) > { > super.onNewIntent(intent); > > Uri uri = intent.getData(); > if (uri != null && uri.toString().startsWith( OAuth.OUT_OF_BAND)) > { > verifier = > uri.getQueryParameter(oauth.signpost.OAuth.OAUTH_VERIFIER); > } > > try { > // this will populate token and token_secret in consumer > provider.retrieveAccessToken(consumer, verifier); > > // TODO: you might want to store token and token_secret in > you app settings!!!!!!!! > AccessToken a = new AccessToken(consumer.getToken(), > consumer.getTokenSecret()); > > // initialize Twitter4J > twitter = new TwitterFactory().getInstance(); > twitter.setOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET); > twitter.setOAuthAccessToken(a); > > // create a tweet > Date d = new Date(System.currentTimeMillis()); > String tweet = "#OAuth working! " + d.toLocaleString(); > > // send the tweet > twitter.updateStatus(tweet); > > // feedback for the user... > tweettx.setText(tweet); > Toast.makeText(this, tweet, Toast.LENGTH_LONG).show(); > login.setVisibility(Button.GONE); > > } catch (Exception e) { > Log.e(APP, e.getMessage()); > Toast.makeText(this, e.getMessage(), > Toast.LENGTH_LONG).show(); > } > > } > > } > > Can you reply fast as its very urgent. > > Thanks > Babita -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

