feat: server-side OAuth token management system

Co-Authored-By: Classic298 <27028174+Classic298@users.noreply.github.com>
This commit is contained in:
Timothy Jaeryang Baek
2025-09-08 18:05:43 +04:00
parent 6d38ac41b6
commit 217f4daef0
10 changed files with 627 additions and 92 deletions

View File

@@ -129,6 +129,21 @@ async def get_tools(
headers["Authorization"] = (
f"Bearer {request.state.token.credentials}"
)
elif auth_type == "oauth":
oauth_token = None
try:
oauth_token = (
await request.app.state.oauth_manager.get_oauth_token(
user.id,
request.cookies.get("oauth_session_id", None),
)
)
except Exception as e:
log.error(f"Error getting OAuth token: {e}")
headers["Authorization"] = (
f"Bearer {oauth_token.get('access_token', '')}"
)
elif auth_type == "request_headers":
headers.update(dict(request.headers))