Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Youtube API returning 401 #380

Closed
pickpj opened this issue Apr 18, 2023 · 2 comments
Closed

Youtube API returning 401 #380

pickpj opened this issue Apr 18, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@pickpj
Copy link

pickpj commented Apr 18, 2023

After setting up the youtube API my header looks like the following [token redacted]:

headers = {"access_token": "............", "expires_in": 62788, "refresh_token": "............", "scope": "https://www.googleapis.com/auth/youtube", "token_type": "Bearer"}
user_id = 

Then when running some command the following error is output

requests.exceptions.InvalidHeader: Header part (62788) from {'expires_in': 62788} must be of type str or bytes, not <class 'int'>

Putting the number in quotes fixes this error; however, a different error is output after searching youtube for the tracks

YouTube tracks: 40/47
Traceback (most recent call last):
  File "/home/lpl/.local/bin/spotify_to_ytmusic", line 8, in <module>
    sys.exit(main())
  File "/home/lpl/.local/lib/python3.10/site-packages/spotify_to_ytmusic/main.py", line 79, in main
    args.func(args)
  File "/home/lpl/.local/lib/python3.10/site-packages/spotify_to_ytmusic/controllers.py", line 54, in create
    playlistId = ytmusic.create_playlist(
  File "/home/lpl/.local/lib/python3.10/site-packages/spotify_to_ytmusic/ytmusic.py", line 19, in create_playlist
    return self.api.create_playlist(name, info, privacy, video_ids=tracks)
  File "/home/lpl/.local/lib/python3.10/site-packages/ytmusicapi/mixins/playlists.py", line 221, in create_playlist
    response = self._send_request(endpoint, body)
  File "/home/lpl/.local/lib/python3.10/site-packages/ytmusicapi/ytmusic.py", line 132, in _send_request
    raise Exception(message + error)
Exception: Server returned HTTP 401: Unauthorized.
You must be signed in to perform this operation.

I imagine it has to do with the access token, but I am unsure how to proceed.

P.S. The URL for setting up the youtube API has a comma appended at the end, which messes up the link.
Edit: Img of URL
urlcomma
Also forgot to mention I am using python 3.10.10

@sigma67
Copy link
Owner

sigma67 commented Apr 18, 2023

Are you sure you didn't add the comma by accident? I'll have to check about the integer bug.

@sigma67 sigma67 transferred this issue from sigma67/spotify_to_ytmusic Apr 19, 2023
@sigma67 sigma67 added the bug Something isn't working label Apr 19, 2023
@sigma67
Copy link
Owner

sigma67 commented Apr 19, 2023

Hi, please update ytmusicapi to 1.0.1 and try again :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants