TwitterKit login issue with webview on Android

android
fabric
twitterkit

#1

Hi All,

I have following code for login, it’s working fine if twitter app installed but getting error in case of webview authentication. I have already added callback url in twitter setting.

Log:
OAuth web view completed with an error
com.twitter.sdk.android.core.identity.WebViewException: net::ERR_TIMED_OUT
at com.twitter.sdk.android.core.identity.OAuthWebViewClient.onReceivedError(OAuthWebViewClient.java:72)
at com.android.webview.chromium.WebViewContentsClientAdapter.onReceivedError(WebViewContentsClientAdapter.java:538)
at com.android.org.chromium.android_webview.AwContentsClient$AwWebContentsObserver.didFailLoad(AwContentsClient.java:84)
at com.android.org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
at com.android.org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:28)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
01-25 07:12:31.080 5094-5094/com.laserlike E/Twitter: Authorization completed with an error
com.twitter.sdk.android.core.TwitterAuthException: OAuth web view completed with an error
at com.twitter.sdk.android.core.identity.OAuthController.handleWebViewError(OAuthController.java:175)
at com.twitter.sdk.android.core.identity.OAuthController.onError(OAuthController.java:202)
at com.twitter.sdk.android.core.identity.OAuthWebViewClient.onReceivedError(OAuthWebViewClient.java:72)
at com.android.webview.chromium.WebViewContentsClientAdapter.onReceivedError(WebViewContentsClientAdapter.java:538)
at com.android.org.chromium.android_webview.AwContentsClient$AwWebContentsObserver.didFailLoad(AwContentsClient.java:84)
at com.android.org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
at com.android.org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:28)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
01-25 07:12:31.081 5094-5094/com.laserlike D/LoginActivity: Login with Twitter failure
com.twitter.sdk.android.core.TwitterAuthException: OAuth web view completed with an error
at com.twitter.sdk.android.core.identity.OAuthController.handleWebViewError(OAuthController.java:175)
at com.twitter.sdk.android.core.identity.OAuthController.onError(OAuthController.java:202)
at com.twitter.sdk.android.core.identity.OAuthWebViewClient.onReceivedError(OAuthWebViewClient.java:72)
at com.android.webview.chromium.WebViewContentsClientAdapter.onReceivedError(WebViewContentsClientAdapter.java:538)
at com.android.org.chromium.android_webview.AwContentsClient$AwWebContentsObserver.didFailLoad(AwContentsClient.java:84)
at com.android.org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
at com.android.org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:28)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

Code:

@Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET);
        Fabric.with(this, new Twitter(authConfig));
        setContentView(R.layout.activity_login);

        mTwitterBtn = (TwitterLoginButton) findViewById(R.id.twitter_login_btn);
        mTwitterBtn.setCallback(new Callback<TwitterSession>() {
            @Override
            public void success(Result<TwitterSession> result) {
                TwitterSession session = result.data;
                
            }

            @Override
            public void failure(TwitterException exception) {
                Log.d(TAG, "Login with Twitter failure", exception);
            }
        });
        
    }

 @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        mTwitterBtn.onActivityResult(requestCode, resultCode, data);
    }

Please suggest me what’s wrong is there. Your valuable comment will be highly appreciated. Thanks


#2

Hey @DilipKumarChau3,

The error you showed seems like a network timeout:

com.twitter.sdk.android.core.identity.WebViewException: net::ERR_TIMED_OUT

are you seeing this consistently across multiple different networks or only on specific network?

-Mike