feat: implement instance ID management and integrate with OAuth token exchange

This commit is contained in:
Junyan Qin
2025-12-29 00:35:31 +08:00
parent ba5b481617
commit de8a7df6c2
4 changed files with 26 additions and 1 deletions

View File

@@ -145,13 +145,15 @@ class UserService:
async def exchange_space_oauth_code(self, code: str) -> typing.Dict:
"""Exchange OAuth authorization code for tokens"""
from langbot.pkg.utils import constants
space_config = self._get_space_config()
space_url = space_config['url']
async with aiohttp.ClientSession() as session:
async with session.post(
f'{space_url}/api/v1/accounts/oauth/token',
json={'code': code},
json={'code': code, 'instance_id': constants.instance_id},
) as response:
if response.status != 200:
raise ValueError(f'Failed to exchange OAuth code: {await response.text()}')