Add external OAuth case to browser check (#396)
This commit is contained in:
parent
2c99445d1b
commit
89c6a2515f
2 changed files with 9 additions and 1 deletions
|
|
@ -6,7 +6,7 @@ import requests
|
|||
from requests.structures import CaseInsensitiveDict
|
||||
|
||||
from ytmusicapi.auth.browser import is_browser
|
||||
from ytmusicapi.auth.oauth import YTMusicOAuth, is_oauth
|
||||
from ytmusicapi.auth.oauth import YTMusicOAuth, is_oauth, is_custom_oauth
|
||||
from ytmusicapi.helpers import initialize_headers
|
||||
|
||||
|
||||
|
|
@ -36,6 +36,9 @@ def prepare_headers(
|
|||
elif is_browser(input_dict):
|
||||
headers = input_dict
|
||||
|
||||
elif is_custom_oauth(input_dict):
|
||||
headers = input_dict
|
||||
|
||||
else:
|
||||
raise Exception(
|
||||
"Could not detect credential type. "
|
||||
|
|
|
|||
|
|
@ -22,6 +22,11 @@ def is_oauth(headers: CaseInsensitiveDict) -> bool:
|
|||
return all(key in headers for key in oauth_structure)
|
||||
|
||||
|
||||
def is_custom_oauth(headers: CaseInsensitiveDict) -> bool:
|
||||
"""Checks whether the headers contain a Bearer token, indicating a custom OAuth implementation."""
|
||||
return "authorization" in headers and headers["authorization"].startswith("Bearer ")
|
||||
|
||||
|
||||
class YTMusicOAuth:
|
||||
"""OAuth implementation for YouTube Music based on YouTube TV"""
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue