[GH-ISSUE #474] Error with Oauth #354

Closed
opened 2026-02-27 23:00:20 +03:00 by kerem · 1 comment
Owner

Originally created by @oraqol on GitHub (Nov 21, 2023).
Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/474

Describe the bug
When using ytmusicapi in I enter point the parameter to the oath.json file that I generated using 'ytmusicapi oauth'. I receive the following error:

"Traceback (most recent call last):
File "/home/user/yt_music/yt_pub_dupe.py", line 9, in
yt = YTMusic('/etc/yt_music/oauth.json')
File "/usr/local/lib/python3.8/dist-packages/ytmusicapi/ytmusic.py", line 124, in init
self.sapisid = sapisid_from_cookie(cookie)
File "/usr/local/lib/python3.8/dist-packages/ytmusicapi/helpers.py", line 81, in sapisid_from_cookie
cookie.load(raw_cookie)
File "/usr/lib/python3.8/http/cookies.py", line 532, in load
for key, value in rawdata.items():
AttributeError: 'NoneType' object has no attribute 'items'"

This is a redacted version of the generated oauth.json file:

"{
"access_token": "XXXX",
"expires_in": "XXX",
"refresh_token": "XXXX",
"scope": "https://www.googleapis.com/auth/youtube",
"token_type": "Bearer",
"expires_at": "XXXX"
}"

This is how I call the python module with the oauth.json file:

"#!/bin/env python

from ytmusicapi import YTMusic
import json
import os
import subprocess
import time

yt = YTMusic('/etc/yt_music/oauth.json')"

To Reproduce
Steps to reproduce the behavior:

  1. Place oath.json in parameter of ytmusicapi function
  2. Run the python script.
  3. View the error above.

Additional context
At first, the 'ytmusicapi oath' command generates a file that has certain numerical config parameters without surrounding quotes, I added the quotes and got the above error. The errors that occur before adding the quotes can be found below:

"requests.exceptions.InvalidHeader: Value for header {expires_in: 60355} must be of type str or bytes, not <class 'int'>

and

requests.exceptions.InvalidHeader: Value for header {expires_at: 1700610566} must be of type str or bytes, not <class 'int'>"

Originally created by @oraqol on GitHub (Nov 21, 2023). Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/474 **Describe the bug** When using ytmusicapi in I enter point the parameter to the oath.json file that I generated using 'ytmusicapi oauth'. I receive the following error: "Traceback (most recent call last): File "/home/user/yt_music/yt_pub_dupe.py", line 9, in <module> yt = YTMusic('/etc/yt_music/oauth.json') File "/usr/local/lib/python3.8/dist-packages/ytmusicapi/ytmusic.py", line 124, in __init__ self.sapisid = sapisid_from_cookie(cookie) File "/usr/local/lib/python3.8/dist-packages/ytmusicapi/helpers.py", line 81, in sapisid_from_cookie cookie.load(raw_cookie) File "/usr/lib/python3.8/http/cookies.py", line 532, in load for key, value in rawdata.items(): AttributeError: 'NoneType' object has no attribute 'items'" This is a redacted version of the generated oauth.json file: "{ "access_token": "XXXX", "expires_in": "XXX", "refresh_token": "XXXX", "scope": "https://www.googleapis.com/auth/youtube", "token_type": "Bearer", "expires_at": "XXXX" }" This is how I call the python module with the oauth.json file: "#!/bin/env python from ytmusicapi import YTMusic import json import os import subprocess import time yt = YTMusic('/etc/yt_music/oauth.json')" **To Reproduce** Steps to reproduce the behavior: 1. Place oath.json in parameter of ytmusicapi function 2. Run the python script. 3. View the error above. **Additional context** At first, the 'ytmusicapi oath' command generates a file that has certain numerical config parameters without surrounding quotes, I added the quotes and got the above error. The errors that occur before adding the quotes can be found below: "requests.exceptions.InvalidHeader: Value for header {expires_in: 60355} must be of type str or bytes, not <class 'int'> and requests.exceptions.InvalidHeader: Value for header {expires_at: 1700610566} must be of type str or bytes, not <class 'int'>"
kerem closed this issue 2026-02-27 23:00:20 +03:00
Author
Owner

@sigma67 commented on GitHub (Dec 11, 2023):

Please state how you solved the issue in case anyone else stumbles upon it

<!-- gh-comment-id:1849630361 --> @sigma67 commented on GitHub (Dec 11, 2023): Please state how you solved the issue in case anyone else stumbles upon it
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#354
No description provided.