tags:

views:

214

answers:

3

Hey out there!

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 AppEnging is described here: http://blog.notdot.net/2010/05/Authenticating-against-App-Engine-from-an-Android-app

A: 

I'm not sure I understand where you want the user to be logged on.

Note that you can't assume which web browser will be sued (default browser, opera mobile, manufacturer browser, etc.) If you only offer an web site, it is the web browser responsibility to know the user. Most people I have already logged in their google account. Android is sort of unrelelated here.

If you want your Android application to connect to a web service without prompting for a login/password, you can't achieve this with openID. I suggest oauth for this use case.

rds
A: 

There is a Open ID library for Java. I can't really find the link right now. But Google it and you will find it. You can then use it to authenticate against you app.

Gooner
+1  A: 

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 = mAccountManager.getAccountsByType("Google"); // (The "Google" is my guess, try the obove code for your self).
// 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!

Aron Cederholm
Have you tried if this helped you?
Aron Cederholm