Hi Eric,
I'm getting the same error as Scott... I get an exception (C#):

System.Net.WebException: The remote server returned an error: (401)
Unauthorized.
     at System.Net.HttpWebRequest.GetResponse()
     at Google.GData.Client.GDataRequest.Execute()

I'm not sure where I'm going wrong here.  I think I'm using the
ClientLogin, so if I'm using a ClientLogin I assume that I don't have
to register a domain (since I'm using a client), so here is my code:

                // Create the Authentication Factory
                GAuthSubRequestFactory authFactory = new
GAuthSubRequestFactory("weaver", "exampleCo-exampleApp-1");

                // Create the Health Service
                _ghService = new HealthService
(authFactory.ApplicationName);

                _ghService.RequestFactory = authFactory;

                // Set the user credentials
                _ghService.setUserCredentials(_username, _password);

                // Authenticate the Credentials
                try
                {
                    String token = _ghService.QueryAuthenticationToken
();

                    System.Windows.Forms.MessageBox.Show("Credentials
Authentication Successful! ",
                        "Credentials authenticated successfully!",
                        System.Windows.Forms.MessageBoxButtons.OK,
 
System.Windows.Forms.MessageBoxIcon.Information);
                }
                catch (Google.GData.Client.InvalidCredentialsException
e)
                {
                    System.Windows.Forms.MessageBox.Show("Invalid
Credentials: " + e.ToString(),
                        "Invalid Credentials!",
                        System.Windows.Forms.MessageBoxButtons.OK,
 
System.Windows.Forms.MessageBoxIcon.Exclamation);
                }

                // Get a user profile
                HealthQuery profileQuery = new HealthQuery(
                    "https://www.google.com/h9/feeds/profile/
default");

                profileQuery.Digest = true;
                HealthFeed feed = _ghService.Query(profileQuery);


The credentials authentication seems to work OK
(QueryAuthenticationToken), but when I try to run a query and I get
the exception.
Any suggestions?
BR,
Kiril

On Dec 18, 4:15 pm, "Eric (Google)" <[email protected]> wrote:
> Hi Scott,
>
> There's not an equivalent H9Service in .NET, but you really don't need
> it.
> Just use the HealthService, but pass it an GDataGAuthRequestFactory
> with
> h9's service name ('weaver').  In C# this would be:
>
> GAuthSubRequestFactory authFactory = new GAuthSubRequestFactory
> ("weaver", "exampleCo-exampleApp-1");
> HealthService service = new HealthService
> (authFactory.ApplicationName);
> service.RequestFactory = authFactory;
> service.setUserCredentials("email", "pwd")
> HealthQuery profileQuery = new HealthQuery("https://www.google.com/h9/
> feeds/profile/default");
>
> Note though, you only need to register a domain for AuthSub.
> If you're building a web app you should be using AuthSub instead of
> ClientLogin.
>
> Eric
>
> On Dec 17, 3:52 pm, ScottB <[email protected]> wrote:
>
> > I'm testing ClientLogin, and I can get it to work just fine against /
> > health, but I get a401error going against h9.  I recently received
> > the email that said that our domain (www.web-aide.com) has been
> > registered.
>
> > Here is my VB.Net Code:
>
> > Dim service As New HealthService(ApplicationName)
>
> > service.setUserCredentials("<user_name>", "<pwd>")
>
> > Dim tq As String = HealthQuery.ProfileListFeed
>
> > tq = tq.Replace("health", "h9")
>
> > Dim query As New HealthQuery(tq)
>
> > Dim feed As HealthFeed  = service.Query(query)
>
> >401is returned with message: Execution of request 
> >failed:https://www.google.com/h9/feeds/profile/list
>
> > When I remove the line "tq = tq.Replace("health", "h9")", I
> > succesfully retrieve profile data for my /health account.  I have
> > doublechecked the user and password on my h9 account.
>
> > I notice from previous posts that there is an H9Service and
> > GoogleService class in the java client library, but don't see an
> > equivalent in the .NET libary.
>
> > Any advice would be greatly appreciated.
>
> > Scott Bergman
> > Castle Technologies, Inc.

--~--~---------~--~----~------------~-------~--~----~
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