How do I get secure AuthSub session tokens in PHP ?

Posted by robertdd on Stack Overflow See other posts from Stack Overflow or by robertdd
Published on 2010-03-26T17:43:38Z Indexed on 2010/03/26 19:53 UTC
Read the original article Hit count: 375

Filed under:
|
|
|

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']);
}

© Stack Overflow or respective owner

Related posts about authsub

Related posts about php