Hi Rajendra,

It looks like you're making some great progress; you're pretty much on
track as far as I can tell!  Using the AccountManager, you should be
able to use an account stored on the Android phone to connect to
Google services.  The example you found for doing this looks similar
to the following:

http://developer.android.com/resources/samples/SampleSyncAdapter/index.html

>From what I understand, you may not need to create a new account, but
you can use a user's Google Android account to get a token to access
Google services.  I'm sill getting up to speed on Android, so the
Android developer forum is likely a much better resource at the
moment, but the following might be a good start:

    AccountManager accountManager = AccountManager.get(this);
    Account[] accounts =
accountManager.getAccountsByType("com.google");
    String authToken =
accountManager.blockingGetAuthToken(accounts[0], null, true);

The next step will be to use the authToken to interact, indirectly,
with Health.  I chatted with some Android, Health, and OAuth engineers
at Google last week, and I have a rough outline of an architecture
that we should be able to use.  I will be documenting the architecture
to make it more clear, but the general structure is to have your
Android phone connect to a intermediary web application that will
access data in Health (Android -> Web App -> Health).  The purpose of
the web app is to allow your system (Android app + web app) to
interact with Health as an "authorized application", which is
documented in the Health developer docs.

Setting up an authorized application:
http://code.google.com/apis/health/getting_started.html#DomainRegistration

Authenticating web app to Health via AuthSub (OAuth should work
similarly):
http://code.google.com/apis/health/docs/2.0/developers_guide_java.html#AuthSub

Example code for interfacing with Health (GData):
http://gdata-java-client.googlecode.com/files/gdata-samples.java-1.41.1.zip

For the intermediary web app, you may want to look at using AppEngine,
which includes APIs for Google authentication.
http://code.google.com/appengine/docs/java/gettingstarted/

So your Android device will communicate with your web app, using the
authToken from the Android AccountManager, and the web app will
communicate to Health using AuthSub/OAuth, GData, and CCR.  One detail
that I'm working on now is how a user will grant your authorized web
application access to their Health profile.  This may require your
Android phone to open a browser window if a user hasn't previously
allowed your web application to access their profile.

A working example will be the absolute best documentation of how this
will all fit together.  If anyone has any code to share, please don't
hesitate to contribute!

Cheers!
p...@google


On Apr 26, 12:24 am, Rajendra <[email protected]> wrote:
> Paul,
>
> I have started using "GData Java Client v2" and trying to use given
> sample picassa applicaion.
>
> I am stuck with the following. When I try to create google account on
> my emulator.
>
> final AccountManager manager = AccountManager.get(this);
> String AccountType = "com.google";
> Account account = new Account(cr.username, AccountType);
> boolean result  = manager.addAccountExplicitly(account, cr.password,
> null);
>
> The last statement gives me error "java.lang.SecurityException: caller
> uid 10027 is different than the authenticator's uid", I tried to find
> the cause but couldn't get it.
>
> I have 
> checkedhttp://www.c99.org/2010/01/23/writing-an-android-sync-provider-part-1/;
>
> Please let me know if anyone has worked on this.
>
> Thanks,
> -Rajendra
>
> On Apr 22, 12:29 pm, Rajendra <[email protected]> wrote:
>
>
>
> > Thank you Paul,
>
> > These forward pointers will really help  me. I Checked "GData Java
> > Client API v2"  source code but it seems to be incomplete
> > as I checked source java files(Especially Health related files).
>
> > I am developing a stand-alone application which authenticates with
> > gmail login and reads user health data.
>
> > Right now I am trying with OAuth but not very sure about it as I can
> > see very few resources around.
>
> > Please let me know if you have any feedback!
>
> > -Rajendra
>
> > On Apr 22, 4:45 am, "Paul (Google)" <[email protected]> wrote:
>
> > > Quick correction on my last post.  I should have wrote "If you *are*
> > > developing a
> > > stand-along Android application...".
>
> > > p...@google
>
> > > On Apr 21, 2:23 pm, "Paul (Google)" <[email protected]> wrote:
>
> > > > Hi Rajendra,
>
> > > > The AuthSub example that you found is for a web application
> > > > authenticating a user.  The httpServletRequest would likely be passed
> > > > into a Servlet by a web app. server via the doGet(ServletRequest,
> > > > ServletResponse) or doPost(..) method.  If you're not developing a
> > > > stand-along Android application, you'll either likely want to look
> > > > into OAuth for installed applications, or consider trying the GData
> > > > Java Client API v2, which includes Android support.
>
> > > > For OAuth, you'll likely want to start at the following 
> > > > site:http://code.google.com/apis/accounts/docs/OAuthForInstalledApps.html
>
> > > > Also, there seems to be a very popular blog on Android+OAuth 
> > > > at:http://donpark.org/blog/2009/01/24/android-client-side-oauth
>
> > > > Finally, the GData Java Client v2 can be found 
> > > > at:http://code.google.com/p/gdata-java-client/wiki/Version2
>
> > > > I hope that these help!  Please be sure to post your findings back to
> > > > the forums!
>
> > > > Cheers!
> > > > p...@google
>
> > > > On Apr 21, 5:25 am, Rajendra <[email protected]> wrote:
>
> > > > > hi,
>
> > > > > I am developing an application to access google health data on
> > > > > android. I am using gdata library(gdata-src.java-1.41.1 on 2.1
> > > > > platform)
>
> > > > > I am referring to article on 
> > > > > pagehttp://code.google.com/apis/gdata/docs/auth/authsub.html
>
> > > > > The following line:
>
> > > > > String singleUseToken =
> > > > > AuthSubUtil.getTokenFromReply(httpServletRequest.getQueryString());
>
> > > > > What does httpServletRequest refer to ? There is no declaration/
> > > > > definition provided in the article.
>
> > > > > If it is related to DoGet, DoPost methods, then how does it work ?
>
> > > > > Please provide me the inputs.
>
> > > > > Thanks and regards,
> > > > > Rajendra Waghmare.
>
> > > > > --
> > > > > You received this message because you are subscribed to the Google 
> > > > > Groups "Google Health 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 
> > > > > athttp://groups.google.com/group/googlehealthdevelopers?hl=en.
>
> > > > --
> > > > You received this message because you are subscribed to the Google 
> > > > Groups "Google Health 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 
> > > > athttp://groups.google.com/group/googlehealthdevelopers?hl=en.
>
> > > --
> > > You received this message because you are subscribed to the Google Groups 
> > > "Google Health 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 
> > > athttp://groups.google.com/group/googlehealthdevelopers?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Google Health 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 
> > athttp://groups.google.com/group/googlehealthdevelopers?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Google Health 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 
> athttp://groups.google.com/group/googlehealthdevelopers?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Health 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/googlehealthdevelopers?hl=en.

Reply via email to