async def auth_mgr(event_loop): mgr = AuthenticationManager( ClientSession(loop=event_loop), "abc", "123", "http://localhost" ) mgr.oauth = OAuth2TokenResponse.parse_raw(get_response("auth_oauth2_token")) mgr.user_token = XAUResponse.parse_raw(get_response("auth_user_token")) mgr.xsts_token = XSTSResponse.parse_raw(get_response("auth_xsts_token")) return mgr
async def auth_mgr(event_loop): session = ClientSession(loop=event_loop) mgr = AuthenticationManager(session, "abc", "123", "http://localhost") mgr.oauth = OAuth2TokenResponse.parse_raw(get_response("auth_oauth2_token")) mgr.user_token = XAUResponse.parse_raw(get_response("auth_user_token")) mgr.xsts_token = XSTSResponse.parse_raw(get_response("auth_xsts_token")) yield mgr await session.close()
def test_save_tokens_to_file(tmpdir, jwt, token_timestring): filepath = os.path.join(str(tmpdir), 'save_tokens.json') auth_manager = AuthenticationManager() auth_manager.access_token = AccessToken(jwt, 1000) auth_manager.xsts_token = XSTSToken(jwt, token_timestring, token_timestring) auth_manager.userinfo = XboxLiveUserInfo(xuid='2535428504476914', userhash='1674471606081042789', gamertag='xboxWebapiGamertag', age_group='Adult', privileges='123 321 432 654', user_privileges='123') auth_manager.dump(filepath) assert os.path.isfile(filepath) is True