Ah, you only use the permission parameter when
requesting the AuthSub token:
http://code.google.com/apis/health/developers_guide_protocol.html#AuthSub

The query should be:

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

Does that work?

Eric

On Sep 17, 5:14 am, Kiran <[EMAIL PROTECTED]> wrote:
> Sorry for late reply.
>
> Code snippet i am using is tha same as the link you have given.
>
>  void PostNotice()
>     {
>         GAuthSubRequestFactory authFactory = new
> GAuthSubRequestFactory("Weaver", "Weaver-Profile-Tester");
>         authFactory.Token = (String)Session["token"];
>         Service service = new Service(authFactory.Service,
> authFactory.ApplicationName);
>         service.RequestFactory = authFactory;
>         AtomEntry newNotice = new AtomEntry();
>         newNotice.Title.Text = Request.Form["subject"];
>         newNotice.Content.Content = Request.Form["message"];
>
>         if (Request.Form["ccr"] != "")
>         {
>             XmlDocument ccrDoc = new XmlDocument();
>             ccrDoc.LoadXml(Request.Form["ccr"]);
>             newNotice.ExtensionElements.Add(ccrDoc.DocumentElement);
>         }
>         try
>         {
>             service.Insert(new Uri("https://www.google.com/h9/feeds/
> register/default"), newNotice);
>             //blank the form elements since .NET loves to save state
>             subject.Text = message.Text = ccr.Text = "";
>         }
>         catch (GDataRequestException e)
>         {
>             Stream receiver = e.Response.GetResponseStream();
>               if (receiver != null)
>               {
>                 // Pipe the stream to ahigher level stream reader with
> the default encoding
>                 // format. which is UTF8
>                 StreamReader readStream = new StreamReader(receiver);
>
>                 // Read 256 charcters at a time.
>                 char []buffer = new char[256];
>                 StringBuilder builder = new StringBuilder(1024);
>                 int count = readStream.Read( buffer, 0, 256);
>                 while (count > 0)
>                 {
>                     //string console.builder.Append(buffer);
>                     count = readStream.Read(buffer,0, 256);
>                 }
>
>                 // Release the resources of stream object.
>                 readStream.Close();
>                 receiver.Close();
>                 Response.Write(builder.ToString());
>               }
>         }
>     }
>
> Also to print profile i am using permission=1
>
> HealthQuery profileQuery = new HealthQuery("https://www.google.com/h9/
> feeds/profile/default?permission=1");
>
> Regards,
> Kiran
>
> On Sep 16, 4:30 am, "Eric (Google)" <[EMAIL PROTECTED]> wrote:
>
> > On Sep 15, 7:41 am, Kiran <[EMAIL PROTECTED]> wrote:
>
> > > i have changed the feed to post notice but i got error saying
> > > "Execution of request failed:https://www.google.com/h9/feeds/register/
> > > default"
>
> > Can you post the snippet of code?
>
> > > and is that everytime i have to confirm linking accounts???
>
> > The user should only link his/her profile once.  After you upgrade
> > the single-use token to a session token, store it in a database
> > or cookie so when the user revisits your site, they won't need
> > to relink their account.
>
> > Eric
>
> > > On Sep 12, 11:04 pm, "Eric (Google)" <[EMAIL PROTECTED]> wrote:
>
> > > > On Sep 12, 4:52 am, Kiran <[EMAIL PROTECTED]> wrote:
>
> > > > > firstly, I am usinghttp://localhostasmyAuthSubnexturl.
>
> > > > > I am using /h9 feeds, and i have checked setting permission=1 to read
> > > > > the profile.
>
> > > > > the problem is still there.
>
> > > > > also i have a question. How can i know that my AuthSub authentication
> > > > > is successful? because everytime i login i have to grant access to
> > > > > application. Or is this the flow for Google Health?
>
> > > > > secondly, with default permission=0 for AuthSub url, i should be able
> > > > > tto post notice, but i am not able to do so, I am getting same error
> > > > > here, ""Execution of request 
> > > > > failed:https://www.google.com/health/feeds/profile/default?digest=true";
>
> > > > That's not the correct feed for posting notices.  It's also a /health
> > > > feed.
>
> > > > Usehttps://www.google.com/h9/feeds/register/defaultforposting
> > > > notices.
>
> > > > See:http://code.google.com/apis/health/developers_guide_protocol.html#Cre...
>
> > > > Eric
>
> > > > > Regards,
> > > > > Kiran
>
> > > > > On Sep 11, 11:29 pm, "Eric (Google)" <[EMAIL PROTECTED]> wrote:
>
> > > > > > Hi Kiran,
>
> > > > > > Your code looks correct.  For those that are following,
> > > > > > it's from the HealthProfile.aspx 
> > > > > > sample:http://code.google.com/p/googlehealthsamples/source/browse/trunk/dotN...
>
> > > > > > I have a few suggestions/question:
>
> > > > > > 1.) Are you usinghttp://localhostasyourAuthSubnexturl?
> > > > > > You won't be able to use an actual domain unless it is
> > > > > > register with both Google and Google Health.
>
> > > > > > See the Getting Started 
> > > > > > Guide:http://code.google.com/apis/health/getting_started.html
>
> > > > > > 2.) In your latest snippet, you are using /h9 (the developer 
> > > > > > sandbox)
> > > > > > feeds but in previous snippets you had /health URIs.  Make sure
> > > > > > to use /h9 feeds for now.
>
> > > > > > 3.) You must set the permission=1 parameter in your AuthSub url
> > > > > > in order to read a user's profile data.  This parameter default to
> > > > > > permission=0,
> > > > > > which means that you can only post notices.
>
> > > > > >  String authSubLink = AuthSubUtil.getRequestUrl("http",
> > > > > > "www.google.com",
> > > > > >                 "/h9/authsub", Request.Url.ToString(), 
> > > > > > "https://www.google.com/h9/feeds/";, false, true);
>
> > > > > > Eric
>
> > > > > > On Sep 11, 2:24 am, Kiran <[EMAIL PROTECTED]> wrote:
>
> > > > > > > I am using the piece of code given in the documentation "http://
> > > > > > > code.google.com/apis/health/developers_guide_dotnet.html "
> > > > > > > Still i am pasting code pieces
>
> > > > > > > code to get token
> > > > > > > String token = Request.QueryString["token"];
> > > > > > >             Session["token"] =
> > > > > > > AuthSubUtil.exchangeForSessionToken(token, null).ToString();
> > > > > > >             Response.Redirect(Request.Url.AbsolutePath, true);
>
> > > > > > > After which i get token.
>
> > > > > > > and the code i use to access profile
>
> > > > > > > GAuthSubRequestFactory authFactory = new
> > > > > > > GAuthSubRequestFactory("weaver", "exampleCo-exampleApp-1");
> > > > > > >         authFactory.Token = (String) Session["token"];
> > > > > > >         HealthService service = new
> > > > > > > HealthService(authFactory.ApplicationName);
> > > > > > >         service.RequestFactory = authFactory;
> > > > > > >         HealthQuery profileQuery = new 
> > > > > > > HealthQuery("https://www.google.com/h9/feeds/profile/default";);
> > > > > > >         profileQuery.Digest = true;
> > > > > > >             HealthFeed feed = service.Query(profileQuery);
> > > > > > >             foreach (HealthEntry entry in feed.Entries )
> > > > > > >             {
> > > > > > >                 XmlNode ccr = entry.CCR; if (ccr != null)
> > > > > > >                 {
> > > > > > >                     Response.Write("<pre>");
> > > > > > >                     StringWriter sw = new StringWriter();
> > > > > > >                     XmlTextWriter xw = new XmlTextWriter(sw);
> > > > > > >                     xw.Formatting = Formatting.Indented;
> > > > > > >                     ccr.WriteTo(xw);
>
> > > > > > > Response.Write(HttpUtility.HtmlEncode(sw.ToString()));
> > > > > > >                     Response.Write("</pre>");
> > > > > > >                 }
> > > > > > >             }
>
> > > > > > > On Sep 11, 1:38 pm, Frank Mantek <[EMAIL PROTECTED]> wrote:
>
> > > > > > > > can you show me the piece of code you are using to:
>
> > > > > > > > a) get the authsubtoken that you want to use?
> > > > > > > > b) set that token to the service object so that it is used for  
> > > > > > > > authentication?
>
> > > > > > > > The credentials will be empty if you are using an authsubtoken.
>
> > > > > > > > Frank
> > > > > > > > On Sep 11, 2008, at 10:11 AM, Kiran wrote:
>
> > > > > > > > > I am using authsub, but i am not able trace the problem.
> > > > > > > > > everytime i get the screen to grant access to application, 
> > > > > > > > > everytime i
> > > > > > > > > grant access and i get token too.
> > > > > > > > > But neither i am able fetch nor post anything.
>
> > > > > > > > > Regards,
> > > > > > > > > Kiran
>
> > > > > > > > > On Sep 10, 2:52 pm, Frank Mantek <[EMAIL PROTECTED]> wrote:
> > > > > > > > >> Yes. If you are getting a 401, then you are not authorized - 
> > > > > > > > >> so your
> > > > > > > > >> code is neither using ClientLogin to setup credentials, nor 
> > > > > > > > >> authsub.
> > > > > > > > >> Did you follow this:
>
> > > > > > > > >>http://code.google.com/apis/health/developers_guide_dotnet.html
>
> > > > > > > > >> to get started?
>
> > > > > > > > >> Regards
>
> > > > > > > > >> Frank Mantek
> > > > > > > > >> Google
> > > > > > > > >> On Sep 10, 2008, at 11:34 AM, Kiran wrote:
>
> > > > > > > > >>> i have gone through them but still problem exists.
> > > > > > > > >>> when i checked for "service.Credentials" it is showing null.
> > > > > > > > >>> is that a problem? because i am getting exception 401: not  
> > > > > > > > >>> authorized.
>
> > > > > > > > >>> On Sep 10, 1:14 pm, Frank Mantek <[EMAIL PROTECTED]> wrote:
> > > > > > > > >>>> Execution of request failed - that is a pretty generic 
> > > > > > > > >>>> error  
> > > > > > > > >>>> message.
> > > > > > > > >>>> There might be more data in the HTML returned by the 
> > > > > > > > >>>> service, to  
> > > > > > > > >>>> see
> > > > > > > > >>>> what that data is, follow the helpful instructions here:
>
> > > > > > > > >>>>http://code.google.com/p/google-gdata/wiki/ErrorHandling
>
> > > > > > > > >>>> and here:
>
> > > > > > > > >>>>http://code.google.com/apis/gdata/articles/debugging_client_libs.html
>
> > > > > > > > >>>> This should get you started in your quest to locate the 
> > > > > > > > >>>> problem.
>
> > > > > > > > >>>> Regards
>
> > > > > > > > >>>> Frank Mantek
> > > > > > > > >>>> Google
>
> > > > > > > > >>>> On Sep 10,
>
> ...
>
> read more »
--~--~---------~--~----~------------~-------~--~----~
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