async def on_startup(self): await Tortoise.init(db_url=os.environ.get("DB_URL"), modules={"models": ["common.models"]}) self.redis = aioredis.from_url(os.environ.get("REDIS_URL"), decode_responses=True) self.session = aiohttp.ClientSession() auth_mgr = AuthenticationManager( self.session, os.environ["XBOX_CLIENT_ID"], os.environ["XBOX_CLIENT_SECRET"], "", ) auth_mgr.oauth = OAuth2TokenResponse.parse_file( os.environ["XAPI_TOKENS_LOCATION"]) await auth_mgr.refresh_tokens() xbl_client = XboxLiveClient(auth_mgr) self.profile = ProfileProvider(xbl_client) self.club = ClubProvider(xbl_client) self.realms = RealmsAPI(aiohttp.ClientSession()) headers = { "X-Authorization": os.environ["OPENXBL_KEY"], "Accept": "application/json", "Accept-Language": "en-US", } self.openxbl_session = aiohttp.ClientSession(headers=headers)
def __attrs_post_init__(self): self.auth_mgr = AuthenticationManager( self.session, os.environ["XBOX_CLIENT_ID"], os.environ["XBOX_CLIENT_SECRET"], "", ) self.auth_mgr.oauth = OAuth2TokenResponse.parse_file( os.environ["XAPI_TOKENS_LOCATION"]) asyncio.create_task(self.refresh_tokens())