The Authorization header is slightly more complex for secure=1 than secure=0 tokens: http://code.google.com/apis/health/developers_guide_protocol.html#AuthSub
In short, you need to create a private key and public certificate to sign requests. Refer to the steps here for registration: http://code.google.com/apis/health/getting_started.html#DomainRegistration and here's code for using AuthSub with secure=1: http://gdatatips.blogspot.com/2008/09/secure-authsub-using-zend-php-library.html Eric On Oct 10, 3:17 pm, "MWW Code" <[EMAIL PROTECTED]> wrote: > Hi Eric, > > Its been quite a while since I wrote and seems that I really need your help. > I have the same problem. Things are running good for our Google Health app > with secure=0, but with secure=1 I get an Error: Token upgrade failed. > Reason: Invalid AuthSub header. Error 401. > > I haven't changed my code since then til we need to use secure=1 that I > found it ain't pushing through. > > Code is as follows: > > function getAuthSubUrl() > { > $next = getCurrentUrl(); > $scope = "https://www.google.com/h9/feeds"; # uncomment upon deployment > $secure = 1; > $session = 1; > return Zend_Gdata_AuthSub::getAuthSubTokenUri($next, $scope, $secure, > $session); > > } > > function requestUserLogin($linkText) > { > $authSubUrl = getAuthSubUrl(); > $authSubUrl = str_replace("/accounts/AuthSubRequest", "/h9/authsub", > $authSubUrl); > $authSubUrl = $authSubUrl . "&permission=1"; > return "<a href=\"{$authSubUrl}\">{$linkText}</a>"; > > } > > function getAuthSubHttpClient() > { > global $_SESSION, $_GET; > if (!isset($_SESSION['sessionToken']) && isset($_GET['token'])) { > $_SESSION['sessionToken'] = > Zend_Gdata_AuthSub::getAuthSubSessionToken($_GET['token'], null, > "https://www.google.com/accounts/AuthSubSessionToken"); //* <-- code gets > preempted here* > } > $client = Zend_Gdata_AuthSub::getHttpClient($_SESSION['sessionToken']); > return $client; > > } > > // the executing code is: > > try{ > $client = getAuthSubHttpClient(); > $healthService = new Zend_Gdata($client); > > $profileFeedUri = > 'https://www.google.com/h9/feeds/profile/default?digest=true'; > $query = new Zend_Gdata_Query($profileFeedUri); > > $feed = $healthService->getFeed($query); --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
