On Sat, Jan 7, 2012 at 6:04 PM, John Goche <[email protected]>wrote:

>
> Hi Nikolay,
>
> On Sat, Jan 7, 2012 at 5:39 PM, Nikolay Elenkov <[email protected]
> > wrote:
>
>> On Sun, Jan 8, 2012 at 1:32 AM, John Goche <[email protected]>
>> wrote:
>>
>> >
>> > Now that you have mentioned AccountManager I have found the following
>> site:
>> >
>> > http://gnuc.in/resources/archives/1404
>> >
>> > I don't know much of what this token is or what it is for.
>>
>
Chapter 15 of the following book mentions the AccountManager:

http://www.amazon.com/Android-Action-Frank-Ableson/dp/1617290505/ref=sr_1_2?ie=UTF8&qid=1325965851&sr=8-2

Basically android can store information from various accounts including
usernames, passords, and auth tokens which
are used so that a user does not have to login again and again (although
these auth tokens can expire depending on
what service they are used to connect to). The book explores authenticating
to LinkedIn from android. The examples
seem to use some OAuth variables with an API specific to LinkedIn. Not sure
how much of this stuff applies to what
I am trying to do. Here the code goes: AccountManager am =
AccountManager.get(ctx); String authToken
= am.getUserData(account, LinkedIn.AUTH_TOKEN); String authTokenSecret =
am.getUserData(account,
LinkedIn.AUTH_TOKEN_SECRET); etc...

Apparently the AccountManager can present an activity to the user where the
user can enter credentials?
Presumably I can use this activity rather than making up my own?

Most references to AccountManager I find in the literature have to do with
the Contacts API since each
contact is tied to an account, such as Chapter 27 of Pro Android
3<http://www.amazon.com/Pro-Android-3-Satya-Komatineni/dp/1430232226/ref=sr_1_1?ie=UTF8&qid=1325968609&sr=8-1>does
an AccountManager.get(ctx).getAccounts()
and iterates through them printing ac.name and ac.type.

There seem to be no books that describe the subject and all of the
information pertaining authenticating to google
accounts for using app engine seems to be on the web.

Interestingly enough, when a user configures an android phone the user is
asked for the credentials of a google account,
although the user may later enter other accounts as well. So assuming the
user has only one google account the following
code may work to retrieve the account:

AccountManager mgr = AccountManager.get(this);
Account[] accts = mgr.getAccountsByType("com.google");
Account acct = accts[0];

and then

mgr.getAuthToken(acct, "android", null, this, null, null);

to retrieve the token?

Anyways, now instead of having the user specify a username and
password for google accounts, I now hoave the user specify an
account. I will keep on reading http://gnuc.in/resources/archives/1404
and see if I can make more sense of it, it's quite a lot of info to digest
but well written it seems, but

right now I am not understanding the presumably Java syntax:

public static void setAuthCookie()
{
    Auth.background()
    {
        @Override
        public void run()
        {
  ...
        }
    });
}

What is Auth.background()?

Can someone please explain the Auth.background()
syntax? I'm not familiar with it.

Any feedback sincerely appreciated,

Regards,

John Goche

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

Reply via email to