Search code examples
androidoauthflickr

Flickr-Android API : Oauth is not redirecting to 'grant-access' page


I'm developing an Android application which requires Flickr API integration. In previous days, I was able to successfully complete the oauth process. But now its not working, and I strongly believe it happend after flickr APIs changed from http:// to https://

Let me explain the situation..

I'm following the steps explained in Flickr API Doc

As a result of the call to http://www.flickr.com/services/oauth/request_token API, I'm successfully receiving the oauth_token.

After this step, I'm presenting Flickr authorization page in a webview with the url specified in API doc (which is somthing similar like, https://www.flickr.com/services/oauth/authorize?oauth_token=72157626737672178-022bbd2f4c2f3432, and of-course, with the oauth_token which I received in the previous step)

Few days before this call was working when I'm using http:// instead of https://. But now, both http:// and https:// are not working. The page is displaying the login screen, but after successful login, the page is not redirecting to the grant access page, instead it is just redirecting to the Flickr Home page. And hence, I'm unable to grant access and unable to receive the oauth_verifier.

Hope I'm well explaining the situation which I'm facing now. But in short, Flickr Login for my application is not working, and I'm running out of time... :(

So, Geeks, Please give some light on the issue...

--Thanks in advance.


Solution

  • Still the issue is there, After oauth Flickr is not redirecting to grant_access page. But I need to get the oauth process successfully completed in my on-going project, as soon as possible. So I have done a workaround to solve the issue.

    To solve the 'not redirecting' issue, I have done a little bit change in my WebView's WebViewClient implementation. It's nothing great, but just redirecting to authorize page again, after successful login.

    Authorize URL Example : https://www.flickr.com/services/oauth/authorize?oauth_token=72157626737672178-022bbd2f4c2f3432

    So, given below is the detailed implementation of WebViewClient:

    mAuthWebView.setWebViewClient(new WebViewClient() {
        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            super.onPageStarted(view, url, favicon);
            showProgressDialog();
    
            /** TODO: This part should be deleted after flickr fixes the oauth redirection issue */ 
            if(url.endsWith("flickr.com/")) {
                mAuthWebView.loadUrl("https://www.flickr.com/services/oauth/authorize?oauth_token=72157626737672178-022bbd2f4c2f3432");
                return;
            }
    
            /* After successful login the redirected url will contain a parameter named 'oauth_verifier' */
            if (url.indexOf("oauth_verifier=") > -1) {
            /* Get the 'oauth_verifier' parameter from url and do next steps */
                    performLoginSuccess();
                }
            }
        }
    
        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            if (url.contains(_my_redirect_url_) && !url.contains("oauth_verifier=")) {
                /* User not authenticated our app */
                finish();
            } else if (!url.contains("oauth_verifier=")) {
                killProgressDialog();
            }
        }
    });
    

    After loading the authorization url, the web view will take the user to login page, and after user successfully loged into Flickr, with web vew client implementation we are again loading the authorization url, to present the grant access page.

    mAuthWebView.loadUrl("https://www.flickr.com/services/oauth/authorize?oauth_token=72157626737672178-022bbd2f4c2f3432");
    

    I know, this is not the right way to do this...
    Any better solutions are always welcome.... :)