-
Notifications
You must be signed in to change notification settings - Fork 762
Closed
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers
Description
Related to huggingface/datasets#7110.
We have a endpoint to check a given user/token has access to a repo: GET /api/{repo_type}s/{repo_id}/auth-check"
. It's especially useful to check permissions on a gated repo. Let's add a auth_check
method to HfApi
based on datasets
implementation:
def check_auth(hf_api, repo_id, token=None):
headers = hf_api._build_hf_headers(token=token)
path = f"{hf_api.endpoint}/api/datasets/{repo_id}/auth-check"
r = get_session().get(path, headers=headers)
hf_raise_for_status(r)
If the user don't have access, a RepoNotFound
or GatedRepoError
error should be raised.
Need to add a proper docstring and tests as well.
mreraser and cjfghk5697albertvillanova and cjfghk5697
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers