23 lines
532 B
Python
23 lines
532 B
Python
import requests
|
|
|
|
API_BASE_URL = "http://127.0.0.1:8000"
|
|
|
|
def login(username: str, password: str):
|
|
url = f"{API_BASE_URL}/api/auth/login/"
|
|
|
|
response = requests.post(url, json={
|
|
"email": username,
|
|
"password": password
|
|
})
|
|
|
|
response.raise_for_status()
|
|
return response.json()
|
|
|
|
def get_me(token: str):
|
|
url = f"{API_BASE_URL}/api/auth/me/"
|
|
response = requests.get(
|
|
url,
|
|
headers={"Authorization": f"Bearer {token}"}
|
|
)
|
|
response.raise_for_status()
|
|
return response.json() |