1

I am building a Twitter client for android using Oauth1.0 and i am stuck somewhere in the middle

    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();
    }



}

Now i have been able to authorize with this , but as soon as i enter my username and password , A pin code appears and no redirection takes place ! Well what i want is to display tweets of the user without entering the Pin Code ! What should i do ?

Thanks in Advance

Anuj
  • 191
  • 1
  • 3
  • 20

1 Answers1

1

First step is to read the documentation on OOB auth on dev.twitter.com

For applications that really can't handle the full OAuth process Twitter provides the out-of-band/PIN code authentication mode, also known as oob.

This authentication flow is almost identical to full OAuth except instead of being directed back to your website the user is presented with a PIN code.

You need to direct the user to your application to enter the supplied PIN code to complete the auth process. If you want redirection, use the full oAuth1.0a flow with either a server component, or make the callback URL a link to open your android application.

markdsievers
  • 6,723
  • 7
  • 46
  • 80
  • where does actually callback url will take , and what exactly one should put into it! B'coz from a user's perpective none will put a pin code into an application – Anuj Oct 10 '11 at 20:19
  • how can i pass a url back to my application ? – Anuj Oct 10 '11 at 20:20
  • See [oAuth flow](https://dev.twitter.com/docs/auth/oauth) for using a callback URL and [this question](http://stackoverflow.com/questions/2958701/launch-custom-android-application-from-android-browser) for launching an app from the browser – markdsievers Oct 10 '11 at 20:25
  • well liked ur pre-edited comment ! Got to figured out and explore before i asked for 'codz' thankx – Anuj Oct 10 '11 at 20:29
  • Cheers - upvote and accept if you are happy and you can move forward with your problem! – markdsievers Oct 10 '11 at 20:49