AndroidBootstrap: Authentication - how does it work?

185 Views Asked by At

I was trying to use http://www.androidbootstrap.com/ to bootstrap a new Android application. It creates a project with Otto, Dagger, Butterknife, Retrofit, and some other nifty stuff while also creating sample code on how to use it. It's really useful, as it sets up the annotation processing and everything in the Gradle build files for Android Studio to import it easily, it's really neat.

However, I'm at a loss with the login screen.

    /**
     * This method gets called when the
     * methods gets invoked.
     * This happens on a different process, so debugging it can be a beast.
     *
     * @param response
     * @param account
     * @param authTokenType
     * @param options
     * @return
     * @throws NetworkErrorException
     */
    @Override
    public Bundle getAuthToken(final AccountAuthenticatorResponse response,
                               final Account account, final String authTokenType,
                               final Bundle options) throws NetworkErrorException {

        Ln.d("Attempting to get authToken");

        final String authToken = AccountManager.get(context).peekAuthToken(account, authTokenType);

        final Bundle bundle = new Bundle();
        bundle.putString(KEY_ACCOUNT_NAME, account.name);
        bundle.putString(KEY_ACCOUNT_TYPE, Constants.Auth.BOOTSTRAP_ACCOUNT_TYPE);
        bundle.putString(KEY_AUTHTOKEN, authToken);

        return bundle;
    }

    @Override
    public String getAuthTokenLabel(final String authTokenType) {
        return authTokenType.equals(Constants.Auth.AUTHTOKEN_TYPE) ? authTokenType : null;
    }

    @Override
    public Bundle hasFeatures(final AccountAuthenticatorResponse response, final Account account,
                              final String[] features) throws NetworkErrorException {
        final Bundle result = new Bundle();
        result.putBoolean(KEY_BOOLEAN_RESULT, false);
        return result;
    }

    @Override
    public Bundle updateCredentials(final AccountAuthenticatorResponse response,
                                    final Account account, final String authTokenType,
                                    final Bundle options) {
        return null;
    }
}

I cannot authenticate it and actually "log in".

So my questions are the following:

  • What is this authenticator authenticating against? The android device account, or Parse.com, or something completely different?
  • How exactly does this authenticator work? Is there a guide somewhere that explains how this should be done (note, on the AndroidBootstrap website, there isn't, and the video guide is outdated) if it weren't for the Bootstrap? To me this looks like a giant mess with random Services (like AccountAuthenticatorService), an AbstractAccountAuthenticator... and while I'm sure it's good for something, it looks needlessly overcomplicated, and I don't understand what is happening.
1

There are 1 best solutions below

0
On BEST ANSWER

As written on https://github.com/AndroidBootstrap/android-bootstrap - the login credentials are

username: [email protected]

password: android

It authenticates you against Parse.com as that is what it is set up against as a demo.

This is using an account authenticator which was added in Android v2.0, and adds the account to the Accounts in Android.

More information is available here:

http://udinic.wordpress.com/2013/04/24/write-your-own-android-authenticator/ http://www.jiahaoliuliu.com/2012/05/android-account-manager-part-i.html http://www.c99.org/2010/01/23/writing-an-android-sync-provider-part-1/