Twitter API returns invalid callback - Cannot authorize

a 夏天 提交于 2019-11-29 13:01:57

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;

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;

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?

Dara Saini
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...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!