Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for /auth-check #2466

Closed
Wauplin opened this issue Aug 20, 2024 · 2 comments
Closed

Add support for /auth-check #2466

Wauplin opened this issue Aug 20, 2024 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@Wauplin
Copy link
Contributor

Wauplin commented Aug 20, 2024

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.

@Wauplin
Copy link
Contributor Author

Wauplin commented Aug 29, 2024

(assigning to @cjfghk5697 see #2444 (comment))

@cjfghk5697 cjfghk5697 mentioned this issue Aug 30, 2024
3 tasks
@Wauplin
Copy link
Contributor Author

Wauplin commented Sep 13, 2024

Closed by #2497. Thanks @cjfghk5697 !

@Wauplin Wauplin closed this as completed Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant