How do I get secure AuthSub session tokens in PHP ?
- by robertdd
I am using the Google/YouTube APIs to develop web application which needs access to a users YouTube account.
Normal unsecure requests work fine and I can upgrade one time tokens to session tokens without any hassle. The problem comes when I try and upgrade a secure token to a session token, I get:
ERROR - Token upgrade for CIzF3546351vmq_P____834654G failed : Token upgrade failed. Reason:
Invalid AuthSub header.
Error 401
i use this:
function updateAuthSubToken($singleUseToken)
{
try {
$client = new Zend_Gdata_HttpClient();
$client->setAuthSubPrivateKeyFile('/home/www/key.pem', null, true);
$sessionToken = Zend_Gdata_AuthSub::AuthSubRevokeToken($sessionToken, $client);
$client->setAuthSubToken($sessionToken);
} catch (Zend_Gdata_App_Exception $e) {
print 'ERROR - Token upgrade for ' . $singleUseToken
. ' failed : ' . $e->getMessage();
return;
}
$_SESSION['sessionToken'] = $sessionToken;
generateUrlInformation();
header('Location: ' . $_SESSION['homeUrl']);
}