[GH-ISSUE #239] Can't authenticate #186

Closed
opened 2026-02-27 22:08:29 +03:00 by kerem · 6 comments
Owner

Originally created by @thomasaldershof on GitHub (Dec 5, 2021).
Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/239

Hello all,

I'm trying to like all songs in a playlist but I keep getting a 403 error. Tried it with Chrome and Firefox headers.
I assume the playlist id is the part after /playlist?list=

Here is my code, hopefully you guys can help me.

`from ytmusicapi.ytmusic import YTMusic

YTMusic.setup(filepath='headers_auth.json')
ytmusic = YTMusic('headers_auth.json')
ytmusic.rate_playlist(playlistId='PL_5iVIEaUI3-mEdwiXDm7e_OTrIIBSo13', rating='LIKE')`

This is the error:
Exception: Server returned HTTP 403: Forbidden.
The caller does not have permission

PS. I don't have a lot of Python experience.

Originally created by @thomasaldershof on GitHub (Dec 5, 2021). Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/239 Hello all, I'm trying to like all songs in a playlist but I keep getting a 403 error. Tried it with Chrome and Firefox headers. I assume the playlist id is the part after /playlist?list= Here is my code, hopefully you guys can help me. `from ytmusicapi.ytmusic import YTMusic YTMusic.setup(filepath='headers_auth.json') ytmusic = YTMusic('headers_auth.json') ytmusic.rate_playlist(playlistId='PL_5iVIEaUI3-mEdwiXDm7e_OTrIIBSo13', rating='LIKE')` This is the error: Exception: Server returned HTTP 403: Forbidden. The caller does not have permission PS. I don't have a lot of Python experience.
kerem closed this issue 2026-02-27 22:08:30 +03:00
Author
Owner

@sigma67 commented on GitHub (Dec 5, 2021):

The code is fine, 403 means that there is an issue with your credentials. Do you have multiple YouTube Music accounts (brand accounts)? If you want me to debug for you, send your headers_auth.json to ytmusicapi@gmail.com

<!-- gh-comment-id:986229550 --> @sigma67 commented on GitHub (Dec 5, 2021): The code is fine, 403 means that there is an issue with your credentials. Do you have multiple YouTube Music accounts (brand accounts)? If you want me to debug for you, send your `headers_auth.json` to ytmusicapi@gmail.com
Author
Owner

@thomasaldershof commented on GitHub (Dec 5, 2021):

Thanks, I will send you an email with the json file. As far as I can see there I don't have a brand account.

<!-- gh-comment-id:986235410 --> @thomasaldershof commented on GitHub (Dec 5, 2021): Thanks, I will send you an email with the json file. As far as I can see there I don't have a brand account.
Author
Owner

@sigma67 commented on GitHub (Dec 5, 2021):

Oh, well now it's obvious. You're trying to add your own playlist to your library, which is obviously impossible. rate_playlist is meant for adding others' playlists to your library.

https://ytmusicapi.readthedocs.io/en/latest/reference.html?highlight=rate_playlist#ytmusicapi.YTMusic.rate_playlist

Your credentials are working fine :) Feel free to log out and log back in to invalidate the credentials you sent me.

<!-- gh-comment-id:986240379 --> @sigma67 commented on GitHub (Dec 5, 2021): Oh, well now it's obvious. You're trying to add your own playlist to your library, which is obviously impossible. `rate_playlist` is meant for adding others' playlists to your library. https://ytmusicapi.readthedocs.io/en/latest/reference.html?highlight=rate_playlist#ytmusicapi.YTMusic.rate_playlist Your credentials are working fine :) Feel free to log out and log back in to invalidate the credentials you sent me.
Author
Owner

@thomasaldershof commented on GitHub (Dec 5, 2021):

Ah thanks, I thought it was used for rating the whole play list liked (so every song). Do you have an idea for that?

<!-- gh-comment-id:986240651 --> @thomasaldershof commented on GitHub (Dec 5, 2021): Ah thanks, I thought it was used for rating the whole play list liked (so every song). Do you have an idea for that?
Author
Owner

@sigma67 commented on GitHub (Dec 5, 2021):

playlist = ytmusic.get_playlist("PL_5iVIEaUI3-mEdwiXDm7e_OTrIIBSo13")
for track in playlist['tracks']:
  ytmusic.rate_song(track['videoId'], 'LIKE')
<!-- gh-comment-id:986242717 --> @sigma67 commented on GitHub (Dec 5, 2021): ```python playlist = ytmusic.get_playlist("PL_5iVIEaUI3-mEdwiXDm7e_OTrIIBSo13") for track in playlist['tracks']: ytmusic.rate_song(track['videoId'], 'LIKE')
Author
Owner

@thomasaldershof commented on GitHub (Dec 5, 2021):

Thanks! Had to run it about 20 times but all songs are liked now!

<!-- gh-comment-id:986246845 --> @thomasaldershof commented on GitHub (Dec 5, 2021): Thanks! Had to run it about 20 times but all songs are liked now!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ytmusicapi#186
No description provided.