android twitter retrieveRequestToken 401 on request token

前端 未结 6 927
走了就别回头了
走了就别回头了 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:36

    using https in place of http in provider

    0 讨论(0)
  • 2020-12-16 16:36

    finally done, check out the following post

    android twitter outh tutorial callback problem

    0 讨论(0)
  • 2020-12-16 16:41

    yes totramon is right...If you are facing problem only while authentication problem , you may have to set device time. I was facing the same problem and solved with this solution only. Also if you are using old twitter api , you need to change it to stable version api(2.1.4). You can find from the following link :

    http://twitter4j.org/en/index.html

    Enjoy..

    0 讨论(0)
  • 2020-12-16 16:47

    I have spent several hours on this. Seems that you have to set ANY value to the callback url in the Settings tab in your Twitter application developer panel. Keeping the default empty value disables dynamic callback urls.

    All the tutorials and all the information I have found online is just void. Twitter long removed the "Client / Website" radio button.

    Moreover, OAuth checks for clock skews.

    0 讨论(0)
  • 2020-12-16 16:51

    I just had the same problem. It only appeared on my dev phone, but on the emulator and another phone the code worked fine. After trying out several solutions to related questions with no luck, eventually it turned out that I had not set the time and date on the dev phone, which doesn't have a sim-card in it. This caused SSL certificates to be invalid and OAuth request to fail, as well as anything else that used HTTPS. After setting the time the problems went away.

    0 讨论(0)
  • 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

    0 讨论(0)
提交回复
热议问题