I am a fresh developer on Googles Android Platform - my HTC Desire arrived last week.
Now i need a way to sign in to my existing application (Java, currently running on jetty). The server Application is developed using spring security 3.0.2
In my case, i want to support the following: If a user has set up his Android phone with a googlemail/google-Account (and most users do) i want to use this account credentials to automagically log in to my server app.
Is there any Android framework supporting that use-case? Or are there any alternatives?
I read: http code.google.com intl/de-DE/apis/accounts/docs/OpenID.html
How we do sign in with an app on google AppEngine is described here: http://blog.notdot.net/2010/05/Authenticating-against-App-Engine-from-an-Android-app
I think what you want is to use AccountManager
To find out what type the google account is, use something like:
AuthenticatorDescription[] types = mAccountManager.getAuthenticatorTypes(); //
for (AuthenticatorDescription type : types) {
Log.d("account types", type.type);
}
Then do something like
AccountManager mAccountManager = AccountManager.get(context);
Account[] mAccounts = AccountManager.get(context).getAccountsByType("com.google");
// Choose which account to use if there are multiple google accounts registered, save to Account mAccount
AccountManagerFuture<options> response = mAccountManager.getAuthToken(mAccount, type, options, activity, mCallback, mHandler); // define callback and handler yourself for where to return
When the user reaches mCallback in your mHandler, the login process is done. The usual google login dialogue will be used if the user is not already logged in to his/her Google account.
Try it out for yourself and let me know if it helped you!