Search in sources :

Example 1 with GoogleAppEngineAuthenticator

use of org.pixmob.httpclient.GoogleAppEngineAuthenticator in project httpclient by pixmob.

the class GoogleAppEngineAuthTask method doRun.

@Override
protected void doRun() throws Exception {
    final AccountManager am = (AccountManager) getContext().getSystemService(Context.ACCOUNT_SERVICE);
    final Account[] accounts = am.getAccountsByType(GoogleAppEngineAuthenticator.GOOGLE_ACCOUNT_TYPE);
    if (accounts == null || accounts.length == 0) {
        throw new IllegalStateException("No Google account found");
    }
    final String gaeHost = "pushpushandroid.appspot.com";
    final GoogleAppEngineAuthenticator auth = new GoogleAppEngineAuthenticator(getContext(), accounts[0], gaeHost);
    final HttpClient hc = createClient();
    hc.head("https://" + gaeHost).with(auth).execute();
}
Also used : Account(android.accounts.Account) GoogleAppEngineAuthenticator(org.pixmob.httpclient.GoogleAppEngineAuthenticator) HttpClient(org.pixmob.httpclient.HttpClient) AccountManager(android.accounts.AccountManager)

Aggregations

Account (android.accounts.Account)1 AccountManager (android.accounts.AccountManager)1 GoogleAppEngineAuthenticator (org.pixmob.httpclient.GoogleAppEngineAuthenticator)1 HttpClient (org.pixmob.httpclient.HttpClient)1