Friday, February 24, 2012

[YouTube-API] Re: Authentication

ok, now i am getting error
Fatal error: Uncaught exception 'Zend_Gdata_App_AuthException' with
message 'Token upgrade failed. Reason:
Invalid token: Token disabled, revoked, or expired.
Error 403
any suggestions


$developerKey =
'AI39si7BhsWEZKk5HtXhHI2Mwlfeo7bAYpmrWt6INMAwm6CPgbr1-2tnlqQkdTM1SllspcpIz0uSrzZKbH8HA0gkmfznQZ_p6Q';
$applicationId = 'Video uploader v1';
$clientId = 'myclientid';

$asToken="1/Efhyd0kmytokenigeneratedmanually";

$_SESSION['sessionToken'] =
Zend_Gdata_AuthSub::getAuthSubSessionToken($asToken);

$httpClient
=Zend_Gdata_AuthSub::getHttpClient($_SESSION['sessionToken']);


$yt = new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId,
$developerKey);
//Add a new playlist

$newPlaylist = $yt->newPlaylistListEntry();
$newPlaylist->summary = $yt->newDescription()->setText('Triathlon
Workout Playlist');
$newPlaylist->title = $yt->newTitle()->setText('MyTri');
// post the new playlist
$postLocation = 'http://gdata.youtube.com/feeds/api/users/wearitliveit/
playlists';
try {
$yt->insertEntry($newPlaylist, $postLocation);
echo"Playlist Created";
}
catch
(Zend_Gdata_App_Exception $e)
{
echo $e->getMessage();
}

On Feb 24, 3:31 pm, Jeffrey Posnick <je...@google.com> wrote:
> Hello,
>
>  That would indicate that your AuthSub token isn't valid. Are you sure
> that it's properly unescaped and that you copied it correctly?
>
> Cheers,
> -Jeff Posnick, YouTube API Team
> groups.google.com/group/youtube-api-gdata | apiblog.youtube.com |
> @YouTubeDev
>
> On Feb 23, 5:56 pm, UStriAthlete <jasoncros...@gmail.com> wrote:
>
>
>
> > getting
> > Expected response code 200, got 401
>
> > Token invalid - Invalid token: Token disabled, revoked, or expired.
>
> > Am i doing something wrong??
>
> > Zend_Loader::loadClass('Zend_Gdata_YouTube');
> > Zend_Loader::loadClass('Zend_Gdata_AuthSub');
>
> > //$yt = new Zend_Gdata_YouTube();
>
> >  $developerKey = 'myDeveloperKey';
> >  $applicationId = 'Video playlist v1';
> >  $clientId = 'clientid';
>
> >   $asToken="mytoken i generated manually";
> >  $httpClient = Zend_Gdata_AuthSub::getHttpClient($asToken);
> >  $yt = new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId,
> > $developerKey);
> >  $yt->setMajorProtocolVersion(2);
>
> > //Add a new playlist
>
> > $newPlaylist = $yt->newPlaylistListEntry();
> > $newPlaylist->summary = $yt->newDescription()->setText('Playlist');
> > $newPlaylist->title = $yt->newTitle()->setText('MyPlaylist');
> > // post the new playlist
> > $postLocation = 'http://gdata.youtube.com/feeds/api/users/default/
> > playlists';
> >         try {
> >         $yt->insertEntry($newPlaylist, $postLocation);
> >         echo"Playlist Created";
> >         }
> >         catch
> >         (Zend_Gdata_App_Exception $e)
> >         {
> >         echo $e->getMessage();
> >         }
>
> > On Feb 21, 3:10 pm, Jeffrey Posnick <je...@google.com> wrote:
>
> > > HelloJason,
>
> > >  There's nothing stopping you from authenticating as your own account
> > > and storing the authentication token in a local database, and then
> > > using it whenever you make the API requests to edit the playlist. You
> > > could do this with AuthSub or other authentication mechanisms. You'd
> > > want to detect the error that is returned when the token expires or is
> > > invalidated and go through the step of generating a new token at that
> > > point (which, in the case of AuthSub/OAuth, would involve you going
> > > through the web sign in flow).
>
> > >  The actual code to accomplish all this is beyond the scope of what we
> > > could provide in this Google Group, but the various client libraries
> > > for the YouTube API do simplify the process of generating, storing,
> > > and reusing auth tokens.
>
> > > Cheers,
> > > -Jeff Posnick, YouTube API Team
> > > groups.google.com/group/youtube-api-gdata | apiblog.youtube.com |
> > > @YouTubeDev
>
> > > On Feb 17, 11:02 am, UStriAthlete <jasoncros...@gmail.com> wrote:
>
> > > > I am making a web page that gathers a subject of videos and adding a
> > > > playlist to my  youtube account.
>
> > > > My question is on the authentication.  How can i authenticate it using my
> > > > credentials so the users of the website do not have to login and allow
> > > > their credentials because the playlist is going to be on my youtube account
> > > > and not theirs?
>
> > > > thanks for your time,
>
> > > >JasonCrossno- Hide quoted text -
>
> > > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -

--
You received this message because you are subscribed to the Google Groups "YouTube APIs Developer Forum" group.
To post to this group, send email to youtube-api-gdata@googlegroups.com.
To unsubscribe from this group, send email to youtube-api-gdata+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/youtube-api-gdata?hl=en.

No comments:

Post a Comment