Linked Questions

Popular Questions

The flow is as follows:

we open an Instagram login page in a web view, user inputs his login and password, then in most of the cases he is asked to verify his account by getting a code by email or phone and entering it on the next page, after doing so, Instagram app opens in a web view and does not redirect to the app. I am unable to get the callback at that time and if i press back button then empty token get.

its working fine when there is no verification from code required.

Thanks!

private class MyWebClient extends WebViewClient {

    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String authorizationUrl) {

        if (authorizationUrl.startsWith(REDIRECT_URI + ACCESS_TOKEN_HASH) && !authorizationUrl.contains(ACCESS_DENIED)) {
            String parts[] = authorizationUrl.split("=");
            String accessToken = parts[1];
            mPreferences.setInstagramAccessToken(accessToken);
            mPresenter.sendTokenBackToActivity(accessToken);
            Toast.makeText(InstagramActivity.this, "AccessToken", Toast.LENGTH_SHORT).show();

            return true;
        } else if (authorizationUrl.contains("?error")) {
            Toast.makeText(InstagramActivity.this, "Error Occured", Toast.LENGTH_SHORT).show();
        }
        onSocialLoginFailed();
        return false;
    }

    @Override
    public void onPageFinished(WebView view, String url) {
        super.onPageFinished(view, url);

    }

    @Override
    public void onPageStarted(WebView view, String url, Bitmap favicon) {
        super.onPageStarted(view, url, favicon);
    }
}

Related Questions