0

Hi I am testing out OAuth authorisation in my app for various sites using a pop-up dialog with an embedded webview where the user can log in and authorise. Works fine for twitter and foursquare. However Tumblr doesn't render properly for some reason.

When I put the authorisation url into a desktop browser everything works fine. However on my phone, whether on a browser on the phone proper or in a webview in my app, all i get is the title "tumblr. Get Ready. It's time. Push the button" plus a blue rectangle and a grey rectangle underneath which I can't interact with.

I have tried putting on javascript settings (Android webview not rendering html content correctly), switching hardware acceleration on and off (Android webview not rendering correctly), or setting storage options (Problems loading mobile.twitter in webview). Nothing works. Would be very grateful if anyone has any ideas!

Many thanks, Riz

Edit: I suspect it's something to do with Chrome n the phone rather than my code as Chrome itself doesn't render Tumblr properly it seems.

Anyway, here is the code I'm using:

public class FragmentOAuthUrlBrowser extends Fragment {
    private static final String REQUEST =     "com.chdryra.android.reviewer.View.ActivitiesFragments.FragmentViewUrlBrowser.url";

    private static final int LAYOUT = R.layout.fragment_review_url_browser;
    private static final int WEB_VIEW = R.id.web_view;

    private OAuthRequest mRequest;

    public static FragmentOAuthUrlBrowser newInstance(OAuthRequest request) {
        return FactoryFragment.newFragment(FragmentOAuthUrlBrowser.class, REQUEST, request);
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle args = getArguments();
        if (args != null) mRequest = args.getParcelable(REQUEST);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View v = inflater.inflate(LAYOUT, container, false);

        WebView webView = (WebView) v.findViewById(WEB_VIEW);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.setWebViewClient(new OAuthWebViewClient());
        webView.loadUrl(mRequest.getAuthorisationUrl());

        return v;
    }

    private class OAuthWebViewClient extends WebViewClient {
        @Override
        public void onPageFinished(WebView view, String url) {
            mRequest.setCallbackResult(view.getUrl());
            super.onPageFinished(view, url);
        }
    }

Here is how it renders: enter image description here

Thanks!

Community
  • 1
  • 1
chdryra
  • 523
  • 5
  • 17

1 Answers1

1

I implemented TumblrLogin. Playing around with Hardware acceleration and storage is not required.

Enable the JavaScript using

//Enable JS support on web browser - important since TumblrLogin utilises JS components to show / hide UI
//Login page will not show up properly if this is not done
webView.getSettings().setJavaScriptEnabled(true);

Set a new WebView client to capture redirections. I found a normal WebViewClient to do the trick. I guess the ChromeWebViewClient should work find too.

That's all. No other customization is required. Hope you're pointing the correct URLs.

<string name="tumblr_request">https://www.tumblr.com/oauth/request_token</string> <string name="tumblr_access">https://www.tumblr.com/oauth/access_token</string> <string name="tumblr_auth">https://www.tumblr.com/oauth/authorize</string>

Clinkz
  • 716
  • 5
  • 18
  • Thanks. I have java script enabled but doesn't help unfortunately. I get to the correct webpage (copy and paste url into browser) just doesn't render properly. – chdryra Mar 10 '16 at 13:44
  • Would you post your code and screenshot of the render please? – Clinkz Mar 17 '16 at 12:49
  • I come across that screen on & off. I just let it load & in time, the blue box turns into the Login button and all is right with the world. Try using [Loglr](https://github.com/dakshsrivastava/Loglr) & check if you still get stuck at that point. If you do, I think its about the phone & browser than the code. – Clinkz Mar 22 '16 at 11:12
  • Thanks - appreciate the help and tips – chdryra Mar 22 '16 at 13:45