android twitter retrieveRequestToken 401 on request token

前端 未结 6 939
走了就别回头了
走了就别回头了 2020-12-16 16:22

I am trying the following sample app for twitter oauth.

http://www.androidsdkforum.com/android-sdk-development/3-oauth-twitter.html

private void askO         


        
6条回答
  •  执念已碎
    2020-12-16 16:54

    **1) **Set date and time to the right values, this will help to fix this issue.****

    2)

    private OAuthConsumer consumer;
    private OAuthProvider provider;
    ...
    ...
    ...
    provider = new CommonsHttpOAuthProvider (
                    TWITTER_REQUEST_TOKEN_URL, 
                    TWITTER_ACCESS_TOKEN_URL,
                    TWITTER_AUTHORIZE_URL);
    
    private void askOAuth() {
            try {
                consumer = new CommonsHttpOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET);
                provider = new CommonsHttpOAuthProvider("http://twitter.com/oauth/request_token",
                                                    "http://twitter.com/oauth/access_token",
                                                    "http://twitter.com/oauth/authorize");
    
                provider.setOAuth10a(true);
    
                String authUrl = provider.retrieveRequestToken(consumer, CALLBACK_URL);
                Toast.makeText(this, "Please authorize this app!", Toast.LENGTH_LONG).show();
                this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(authUrl)));
            } catch (Exception e) {
                Log.e(APP, e.getMessage());
                Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
            }
        }
    

    3) is your twitter app configured as Browser? try with this keys:

    Consumer key

    sdOjEI2cOxzTLHMCCMmuQ

    Consumer secret

    biI3oxIBX2QMzUIVaW1wVAXygbynuS80pqSliSDTc

提交回复
热议问题