Search code examples
youtubeoauth-2.0gdatafavorite

Deleting a YouTube favorite when authenticated with OAuth2


I'm trying to delete a favorite using YouTube API. As Google recently deprecated AuthSub authentication method, I've decided to choose the officially recommended OAuth2 authentication method.

I'm able to set a video as favorite, but when I try to delete it using the described method in the docs, the response is :

Only the favorite owner can remove it.

I'm using the Google OAuth2 Playground, and I'm able to set a video as favorite so I'm pretty much sure that there is no error with the authentication, but still, it doesn't work.

The request I'm making is the following :

DELETE /feeds/api/users/default/favorites/nq3gs6PG8-E HTTP/1.1
Host: gdata.youtube.com
X-gdata-key: key=DEVELOPER_KEY
Content-length: 0
Authorization: OAuth ACCESS_TOKEN
----------------------------------------
HTTP/1.1 403 Forbidden
Content-length: 38
X-xss-protection: 1; mode=block
X-content-type-options: nosniff
X-google-cache-control: remote-fetch
-content-encoding: gzip
Server: GSE
Reason: Forbidden
Via: HTTP/1.1 GWA
X-gdata-user-country: US
Cache-control: private, max-age=0
Date: Thu, 20 Sep 2012 17:53:19 GMT
X-frame-options: SAMEORIGIN
Content-type: text/html; charset=UTF-8
Expires: Thu, 20 Sep 2012 17:53:19 GMT

Only the favorite owner can remove it.

I do have set the "nq3gs6PG8-E" video as favorite, and my DEVELOPER_KEY and ACCESS_TOKEN are correct.

I'm wondering if there is a fix, or something I'm missing ? I wouldn't want to roll back on a deprecated authentication method, that wouldn't be safe, but do I have any choice ?


Solution

  • Please see https://developers.google.com/youtube/2.0/developers_guide_protocol_favorites#Deleting_a_favorite_video

    Specifically, this note:

    The ID that you use to delete a favorite video is not the for that video but a different value that uniquely associates the video with the user who marked it as a favorite. To delete a favorite video, always send the DELETE request to the edit URL that the favorite videos feed specifies for the video.