-
Notifications
You must be signed in to change notification settings - Fork 0
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
login with OpenAI token #28
Comments
We could do this in this way, possibly? import openai
import requests
from requests import HTTPError
def login(key: str):
url = "https://api.openai.com/v1/engines"
headers = {
'Authorization': f"Bearer {key}"
}
r = requests.get(url=url, headers=headers)
try:
r.raise_for_status()
except HTTPError as e:
raise ValueError("Login failed")
else:
print(f"Logged in with (The key is valid): {key}. The key is NOT stored in any databases whatsover")
def main():
# this is where that is stored
login(openai.api_key)
login("haha")
if __name__ == '__main__':
main()
|
but note - we should still have a master key.
|
eubinecto
added a commit
that referenced
this issue
May 21, 2022
eubinecto
added a commit
that referenced
this issue
May 21, 2022
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What is a simple way of.. just testing if the API token is valid?
The text was updated successfully, but these errors were encountered: