I was experimenting with the REST API with a private repo. Despite providing the user access token in the request header, I receive an error
import requests
from dotenv import load_dotenv
load_dotenv()
per_token = os.getenv('API_PER_TOKEN')
headers = {"Authorization": f"Bearer {per_token}"}
API_URL = "https://datasets-server.huggingface.co/is-valid?dataset=sl02/np-datasets"
def query():
response = requests.request("GET", API_URL, headers=headers)
return response.json()
data = query()
{'error': 'The dataset does not exist, or is not accessible without authentication (private or gated). Please retry with authentication.'}
However, when I make the repository public, it returns {'valid': True}
. But, when I run the first-rows
API, I get the following message
import requests
from dotenv import load_dotenv
load_dotenv()
per_token = os.getenv('API_PER_TOKEN')
headers = {"Authorization": f"Bearer {per_token}"}
API_URL = "https://datasets-server.huggingface.co/first-rows?dataset=sl02/np-datasets&config=default&split=train"
def query():
response = requests.request("GET", API_URL)
return response.json()
data = query()
{'error': 'The response is not ready yet. Please retry later.'}
The load_dataset()
works in private mode when I set the use_auth_token
argument. Any clue what I missing here?