Thanks for responding eric.

Sorry about that. Here's the complete code. my feed query is "https://
www.google.com/h9/feeds/profile/default/-/medication" which is placed
on a configuration file. When I test it using secure=false everything
is working. But when I change the authsublink to implement secure
tokens error 401 appears. Is it a cert issue or something is wrong in
my code?

            String token = Request.QueryString["token"];
            String rsaKey =
ConfigurationManager.AppSettings["google_rsa_key"];
            String googleSessionToken;
            if (rsaKey == string.Empty)
                googleSessionToken =
AuthSubUtil.exchangeForSessionToken(token, null).ToString();
            else
            {
                X509Certificate2 temp = new X509Certificate2(rsaKey,
ConfigurationManager.AppSettings["google_rsa_password"]);
                RSACryptoServiceProvider privateKey = temp.PrivateKey
as RSACryptoServiceProvider;
                googleSessionToken =
AuthSubUtil.exchangeForSessionToken(token, privateKey).ToString();
            }
            Session[GlobalConst.GOOGLETOKEN] = googleSessionToken;


And for retreiving the feed here's the code


GAuthSubRequestFactory authFactory = new
GAuthSubRequestFactory(ConfigurationManager.AppSettings["google_service_nam­
e"],
ConfigurationManager.AppSettings["google_app_name"]);
        authFactory.Token = (String)Session[GlobalConst.GOOGLETOKEN];
        String rsaKey =
ConfigurationManager.AppSettings["google_rsa_key"];


        if (rsaKey != string.Empty)
        {
            X509Certificate2 temp = new
X509Certificate2(rsaKey,ConfigurationManager.AppSettings["google_rsa_passwo­
rd"]);
            RSACryptoServiceProvider privateKey = temp.PrivateKey as
RSACryptoServiceProvider;
            authFactory.PrivateKey = privateKey;
        }


        Service service = new Service(authFactory.Service,
authFactory.ApplicationName);
        service.RequestFactory = authFactory;

FeedQuery query = new FeedQuery();
        query.Uri = new
Uri(ConfigurationManager.AppSettings["google_feedquery_uri"]);
        query.ExtraParameters =
ConfigurationManager.AppSettings["google_query_parameters"];

AtomFeed healthFeed = service.Query(query);

On Sep 30, 6:48 pm, "Eric (Google)" <[EMAIL PROTECTED]> wrote:
> Hi unggoi,
>
> I don't seem where you're querying a feed.  Your code
> seems to stop at creating the service object.
>
> Here's a C# example that worked for 
> me:http://code.google.com/p/googlehealthsamples/source/browse/trunk/dotN...
>
> Eric
>
> On Sep 30, 6:16 pm, unggoi <[EMAIL PROTECTED]> wrote:
>
>
>
> > I'm getting a 401 error unauthorized when I'm using a secure token.
> > Everything works fine when I set secure to false. Is there something
> > wrong on my code or is this a cert issue?
> > I have domain.pfx and domain.cer is this correct? Please help and
> > thank you very much in advance.
>
> > Here's my code
>
> >             String token = Request.QueryString["token"];
> >             String rsaKey =
> > ConfigurationManager.AppSettings["google_rsa_key"];
> >             String googleSessionToken;
> >             if (rsaKey == string.Empty)
> >                 googleSessionToken =
> > AuthSubUtil.exchangeForSessionToken(token, null).ToString();
> >             else
> >             {
> >                 X509Certificate2 temp = new X509Certificate2(rsaKey,
> > ConfigurationManager.AppSettings["google_rsa_password"]);
> >                 RSACryptoServiceProvider privateKey = temp.PrivateKey
> > as RSACryptoServiceProvider;
> >                 googleSessionToken =
> > AuthSubUtil.exchangeForSessionToken(token, privateKey).ToString();
> >             }
> >             Session[GlobalConst.GOOGLETOKEN] = googleSessionToken;
>
> > And for retreiving the feed here's the code
>
> > GAuthSubRequestFactory authFactory = new
> > GAuthSubRequestFactory(ConfigurationManager.AppSettings["google_service_nam 
> > e"],
> > ConfigurationManager.AppSettings["google_app_name"]);
> >         authFactory.Token = (String)Session[GlobalConst.GOOGLETOKEN];
> >         String rsaKey =
> > ConfigurationManager.AppSettings["google_rsa_key"];
>
> >         if (rsaKey != string.Empty)
> >         {
> >             X509Certificate2 temp = new
> > X509Certificate2(rsaKey,ConfigurationManager.AppSettings["google_rsa_passwo 
> > rd"]);
> >             RSACryptoServiceProvider privateKey = temp.PrivateKey as
> > RSACryptoServiceProvider;
> >             authFactory.PrivateKey = privateKey;
> >         }
>
> >         Service service = new Service(authFactory.Service,
> > authFactory.ApplicationName);
> >         service.RequestFactory = authFactory;- Hide quoted text -
>
> - Show quoted text -

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