diff --git a/src/evaluate/utils/file_utils.py b/src/evaluate/utils/file_utils.py index 53bbf1c5..4c278905 100644 --- a/src/evaluate/utils/file_utils.py +++ b/src/evaluate/utils/file_utils.py @@ -226,16 +226,10 @@ def get_authentication_headers_for_url(url: str, token: Optional[Union[str, bool """Handle the HF authentication""" headers = {} if url.startswith(config.HF_ENDPOINT): - if token is False: - token = None - elif isinstance(token, str): - token = token - else: - from huggingface_hub import hf_api + from huggingface_hub.utils import build_hf_headers + + headers = build_hf_headers(token=token, library_name="evaluate", library_version=__version__) - token = hf_api.HfFolder.get_token() - if token: - headers["authorization"] = f"Bearer {token}" return headers