Take the 2-minute tour ×
Stack Apps is a question and answer site for apps, scripts, and development with the Stack Exchange API. It's 100% free, no registration required.

I think my questions is not a duplicate of this one How to login programmatically

I have read the authentication document but still i am not able to get what should I do for if I want to perform login activity programmatically using Android code. I mean which url should I pass to perform login activity ?

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

Use implicit OAuth flow. Load the specified URL with necessary query parameters into a webview and when authentication is done you can get the access_token from the redirect_uri. You can have the webview handle the redirect_uri by setting a custom webview client.

Example:

private class ExampleWebViewClient extends WebViewClient
{
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url)
        {

            if (url.startsWith(MY_REDIRECT_URI))
            {
                //parse the URL here to get the access_token
                return true;
            }

            return false;
        }
}

And while initializing the webview, do

webview.setWebViewClient(new ExampleWebViewClient());
share|improve this answer
    
ok, so for login i must use webview only ? there is no method like a webservice. In case of above webview what could be a URL, can yo u give me a sample url please ? –  Raynold Apr 17 '13 at 17:02
add comment

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .