To reply to your more specific questions, it is my understanding that
the type you see in your log output is the type you would pass in to
most of the AccountManager functions.  The type should be a java style
universally unique name (ie: domain.subdomain.accounttype) in the form
of a string.  So if you wanted to get a Google Auth Token you would
call getAuthToken and pass in "com.google", for facebook you would
pass in "com.facebook.auth.login".

I am working on building my own account authenticator now and it's
quite a bit more work than actually getting the auth token.  Basically
anywhere on your Droid that you see Google, Facebook and Exchange you
could add your own account type, as well as allow applications by
other developers to authenticate with your service.

Here is the flow as I understand it, along with links to documentation
for each part:
http://docs.google.com/View?id=dhhtdbc7_4hhh4whg8

Basically once you have an authenticator written and installed on the
user's phone then the user would first need to create an account with
the authenticator.

One authenticator may track credentials for multiple users.  ex: I may
sign-in to the phone with two Google Accounts, then any app that needs
an auth token for "com.google" would need to prompt the user with both
accounts and ask them which one they would like to use.

Once there is one or more accounts setup with the authenticator you
would then ask the authenticator for an auth token for the desired
account.  The authenticator then may (or may not) prompt the user for
additional credentials or it may pass an intent back to the calling
application (depending on which version of getAuthToken you call) and
leave it up to the calling application to send off the credential
request intent (ex: if you are authenticating in the background it may
be better to wait for the user to switch back to your app before
prompting them, or pop-up a notification).

Once authentication is complete the calling application will get a
callback letting it know the results (auth token or failure).  The
calling application can then use that auth token to access services
provided by "com.google" (or whoever you authenticated with), likely
over an SSL connection, so the auth token isn't stolen.

On Nov 9, 5:00 pm, Nerdrow <troybe...@gmail.com> wrote:
> I just tried this real quick on my Droid:
>
> AccountManager mgr = AccountManager.get(this);
> Account[] accts = mgr.getAccounts();
> final int count = accts.length;
> Account acct = null;
>
> for(int i=0;i<count;i++) {
>   acct = accts[i];
>   Log.d("ACCT", "eclair account - name="+acct.name+",
> type="+acct.type);
>
> }
>
> These are the results (masked :))
>
> 11-09 16:13:09.143: DEBUG/ACCT(2495): eclair account -
> name=<myemail>@gmail.com, type=com.google
> 11-09 16:13:09.143: DEBUG/ACCT(2495): eclair account -
> name=<myfacebook>@<facebook_email>.com, type=com.facebook.auth.login
> 11-09 16:13:09.143: DEBUG/ACCT(2495): eclair account -
> name=<myworkmail>@<mycompany>.com, type=com.android.exchange
>
> Do you understand how to actually use the returned Account objects?
> It looks like you have to use an AccountManager instance and call the
> getAuthToken method, but this keeps failing for me since I don't know
> the authTokenType to pass as an input parameter.  The Account object
> itself has no other useful fields as far as I can tell.
>
> Related is the AbstractAccountAuthenticator, where you're supposed to
> be able to add authenticator types to appear on the phone (by default
> on the Droid you get 3, Google, Facebook, and Exchange).  Judging by
> the documentation this would allow you to integrate your app into the
> "quick contact bar" or whatever it's called, as well as use the
> ContactsContract api to facilitate contact syncing, but there's no
> examples around any of this stuff, just the documentation.  I found
> this thread about the ContactsContract, but it doesn't help if I can't
> add my authenticator 
> first:http://groups.google.com/group/android-developers/browse_thread/threa...
>
> Anyone have any ideas?
>
> On Nov 8, 9:21 pm, Micah <mi...@zoltu.net> wrote:
>
>
>
> > In Android 2.0 there is a new android.accounts.AccountManagerclass
> > has a function getAccounts()
> > see:http://developer.android.com/reference/android/accounts/AccountManage...()
>
> > Unfortunately, as most of you know the SDK doesn't come with any of
> > the Google Apps that utilize the Google Account associated with the
> > phone (Gmail, Google Talk, Calendar, etc.).  This means that when you
> > call getAccounts in an emulator it returns an empty array.
>
> > The *hope* is that Google has modified the Google apps shipped with
> > Android 2.0 to use theAccountManagerAPI instead of whatever internal
> > and super-secret-closed system they were using before.  If this is the
> > case, then 3rd party apps can hopefully gain access to a Google Auth
> > token via theAccountManagerinstead of having to ask the user for
> > their username / password.
>
> > Unfortunately, the only phone that has android 2.0 on it to my
> > knowledge is the Motorola Droid.  So this is a call out to any
> > developers that have access to that phone to please 
> > callAccountManager.getAccounts and let us know whether or not there is a
> > Google Account on a production android device.
>
> > If not then it appears that it will be up to 3rd party developers to
> > write an Authenticator (ideally a free / open sourced one) that
> > returns a Google Auth token (and prompts / stores user's Google
> > credentials with the android.accounts API.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to