From 5f1945ae056c765a4576ce9d9754745d117e7803 Mon Sep 17 00:00:00 2001 From: jcbirdwell Date: Tue, 19 Dec 2023 13:59:35 -0600 Subject: [PATCH] remove: env support --- ytmusicapi/auth/oauth.py | 18 ------------------ ytmusicapi/setup.py | 16 ++-------------- 2 files changed, 2 insertions(+), 32 deletions(-) diff --git a/ytmusicapi/auth/oauth.py b/ytmusicapi/auth/oauth.py index 8e68e3f..528a6f7 100644 --- a/ytmusicapi/auth/oauth.py +++ b/ytmusicapi/auth/oauth.py @@ -2,7 +2,6 @@ import json import time import webbrowser from typing import Dict, Optional, Any -from os import environ as env import os import requests @@ -88,23 +87,6 @@ class OAuthToken: class OAuthCredentials: - @classmethod - def from_env(cls, - session: Optional[requests.Session] = None, - proxies: Optional[Dict] = None, - *, - client_id_key='YTMA_OAUTH_CLIENT_ID', - client_secret_key='YTMA_OAUTH_CLIENT_SECRET'): - missing_keys = [x for x in [client_id_key, client_secret_key] if x not in env] - if missing_keys: - raise KeyError('Failed to build credentials from environment. Missing required keys: ', - missing_keys) - - return cls(client_id=env[client_id_key], - client_secret=env[client_secret_key], - session=session, - proxies=proxies) - def __init__(self, client_id: Optional[str] = OAUTH_CLIENT_ID, client_secret: Optional[str] = OAUTH_CLIENT_SECRET, diff --git a/ytmusicapi/setup.py b/ytmusicapi/setup.py index 20f051f..f826ec4 100644 --- a/ytmusicapi/setup.py +++ b/ytmusicapi/setup.py @@ -26,7 +26,6 @@ def setup_oauth(filepath: str = None, session: requests.Session = None, proxies: dict = None, open_browser: bool = False, - env_credentials: bool = False, client_id: str = None, client_secret: str = None) -> Dict: """ @@ -37,13 +36,8 @@ def setup_oauth(filepath: str = None, :param proxies: Proxies to use for authentication :param filepath: Optional filepath to store headers to. :param open_browser: If True, open the default browser with the setup link - :param env_credentials: Optional. Specifies if client_id and client_secret should be - pulled from the environment. Modifies client_id and client_secret parameters to - instead specify the keys to search environment for. Default keys are - YTMA_OAUTH_CLIENT_ID for client_id and YTMA_OAUTH_CLIENT_SECRET for secret. :param client_id: Optional. Used to specify the client_id oauth should use for authentication - flow. If used with env_credentials, instead specifies the environmental key of client_id. - If not used with env_credentials, client_secret MUST also be passed or both will be ignored. + flow. If provided, client_secret MUST also be passed or both will be ignored. :param client_secret: Optional. Same as client_id but for the oauth client secret. :return: configuration headers string @@ -51,13 +45,7 @@ def setup_oauth(filepath: str = None, if not session: session = requests.Session() - if env_credentials: - oauth_credentials = OAuthCredentials.from_env(session, - proxies, - client_id_key=client_id, - client_secret_key=client_secret) - - elif client_id and client_secret: + if client_id and client_secret: oauth_credentials = OAuthCredentials(client_id, client_secret, session, proxies) else: