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 API tokens and a unique exception #8

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jonahclarsen
Copy link

No description provided.

@narugo1992 narugo1992 requested review from narugo1992 and removed request for narugo1992 January 20, 2025 04:28
@@ -51,6 +51,12 @@ def download_file(url, filename, expected_size: int = None, desc=None, session=N
:rtype: str
"""
session = session or requests.session()

if "CIVITAI_API_TOKEN" in os.environ:
url = url + ("&" if "?" in url else "?") + "token=" + os.environ['CIVITAI_API_TOKEN']
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i suggest we can use the http header to do the authorization, instead of modifying the url by string operations.

https://github.com/civitai/civitai/wiki/REST-API-Reference#authorization

if "CIVITAI_API_TOKEN" in os.environ:
url = url + ("&" if "?" in url else "?") + "token=" + os.environ['CIVITAI_API_TOKEN']
else:
print("No token found.")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm, do not directly print this, log this with low levels (like debug/info)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants