- Created .gitignore to exclude virtual environment, logs, and database files. - Updated README.md with project description, features, folder structure, requirements, and usage instructions. - Implemented versioning and developer ID in agentm/__init__.py. - Developed main application logic in agentm/app.py, including credential handling and screen navigation. - Added database initialization and ROM management logic in agentm/logic/db.py and agentm/logic/db_functions.py. - Integrated DIAMBRA login functionality in agentm/logic/diambra_login.py. - Created ROM verification and caching system in agentm/logic/roms.py. - Designed user interface components for home and login screens in agentm/views/home.py and agentm/views/login.py. - Added logging utility in agentm/utils/logger.py for better debugging and tracking. - Included assets such as game images, styles, and logos. - Updated requirements.txt with necessary dependencies for the project.
29 lines
991 B
Python
29 lines
991 B
Python
import requests
|
|
from agentm import DIAMBRA_CREDENTIALS_PATH
|
|
from agentm.utils.logger import log_with_caller
|
|
|
|
LOGIN_API = "https://api.diambra.ai/api/auth/token/"
|
|
|
|
def login_to_diambra(email: str, password: str) -> str:
|
|
"""Log in to DIAMBRA and retrieve API token from /v1alpha1/token."""
|
|
payload = {
|
|
"username": email,
|
|
"password": password
|
|
}
|
|
|
|
response = requests.post("https://api.diambra.ai/api/v1alpha1/token", json=payload)
|
|
response.raise_for_status()
|
|
|
|
token = response.json().get("token")
|
|
if not token:
|
|
raise Exception("Login succeeded but no token returned.")
|
|
|
|
log_with_caller("info", f"Successfully retrieved DIAMBRA token: {token[:6]}...")
|
|
return token
|
|
|
|
def save_diambra_token(token: str):
|
|
"""Writes the token to the .diambra/credentials file with no trailing newline."""
|
|
DIAMBRA_CREDENTIALS_PATH.write_bytes(token.encode("utf-8"))
|
|
log_with_caller("info", f"Saved DIAMBRA token to: {DIAMBRA_CREDENTIALS_PATH}")
|
|
|