Twitter API returns invalid callback - Cannot authorize

后端 未结 4 1249
抹茶落季
抹茶落季 2020-12-20 08:45

[SOLVED, but I\'m open to new suggestions...]

I\'m integrating Twitter into my Android app using twitter4j.

When I try to authorize with Twitter,

相关标签:
4条回答
  • 2020-12-20 09:23

    I guess there is nothing wrong with your code. I was getting the same result yesterday, but today it works like a charm. It is probably a server side issue. Could you try again your original (with no hacky part) solution, pls?

    0 讨论(0)
  • 2020-12-20 09:24

    Use Below CallBack_URI for that, it may help you.

    public static final String  OAUTH_CALLBACK_SCHEME = "x-oauthflow-twitter";
    public static final String  OAUTH_CALLBACK_HOST = "callback";
    public static final String  CALLBACK_URL = OAUTH_CALLBACK_SCHEME + "://" + OAUTH_CALLBACK_HOST;
    
    0 讨论(0)
  • 2020-12-20 09:31

    I found I just could not get it to work this way after following the guides I've seen online.

    I ended up using my own custom WebViewClient with the code:

    if ( url.contains( "MY-CALLBACK:///" ) )
    {
        final int start = url.indexOf( '?' ) + 1;
        final String params = url.substring( start );
        final String verifierToken = "oauth_verifier=";
        if ( params.contains( verifierToken ) )
        {
            final int value = params.indexOf( verifierToken ) + verifierToken.length();
            final String token = params.substring( value );
            view.stopLoading();                  
            authoriseNewUser( token );
        }
        else if ( params.contains( "denied" ) )
        {
            view.stopLoading();
            finish();
        }
    }
    else
    {
        view.loadUrl( url );
    }
    return true;
    
    0 讨论(0)
  • 2020-12-20 09:34
    public static final String OAUTH_CALLBACK_SCHEME = "x-oauthflow-twitter";
    public static final String OAUTH_CALLBACK_HOST = "litestcalback";
    public static final String OAUTH_CALLBACK_URL = OAUTH_CALLBACK_SCHEME+ "://" +OAUTH_CALLBACK_HOST;
    

    use this type of callback_url in code and manifest file...

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