(self)
| 21 | class KaggleWebClient: |
| 22 | |
| 23 | def __init__(self): |
| 24 | url_base_override = os.getenv(_KAGGLE_URL_BASE_ENV_VAR_NAME) |
| 25 | self.url_base = url_base_override or _KAGGLE_DEFAULT_URL_BASE |
| 26 | # Follow the OAuth 2.0 Authorization standard (https://tools.ietf.org/html/rfc6750) |
| 27 | self.jwt_token = os.getenv(_KAGGLE_USER_SECRETS_TOKEN_ENV_VAR_NAME) |
| 28 | if self.jwt_token is None: |
| 29 | raise CredentialError( |
| 30 | 'A JWT Token is required to call Kaggle, ' |
| 31 | f'but none found in environment variable {_KAGGLE_USER_SECRETS_TOKEN_ENV_VAR_NAME}') |
| 32 | self.headers = { |
| 33 | 'Content-type': 'application/json', |
| 34 | 'X-Kaggle-Authorization': f'Bearer {self.jwt_token}', |
| 35 | } |
| 36 | iap_token = os.getenv(_KAGGLE_IAP_TOKEN_ENV_VAR_NAME) |
| 37 | if iap_token: |
| 38 | self.headers['Authorization'] = f'Bearer {iap_token}' |
| 39 | |
| 40 | def make_post_request(self, data: dict, endpoint: str, timeout: int = TIMEOUT_SECS) -> dict: |
| 41 | url = f'{self.url_base}{endpoint}' |
nothing calls this directly
no test coverage detected