Ejemplo n.º 1
0
 async def authenticate_device(self, username: str, create_user: bool = True) -> NakamaSession:
     _data = {'id': str(getnode())}
     _params = {'create': str(create_user).lower(), 'username': username}
     async with aiohttp.ClientSession() as session:
         async with session.post(
                 f'{self.base_url}/account/authenticate/device', params=_params,
                 json=_data, headers=self.base_header) as resp:
             r = await resp.json()
             if resp.status != 200:
                 raise NakamaError(http_code=resp.status, error_name=r['error'], grpc_code=r['code'],
                                   message=r['message'])
             return NakamaSession(token=r['token'])
Ejemplo n.º 2
0
 async def authenticate_facebook(self, token: str, username: str, create_user: bool = True,
                                 import_friends: bool = True) -> NakamaSession:
     _data = {'token': token}
     _params = {'create': str(create_user).lower(), 'username': username, 'import': str(import_friends).lower()}
     async with aiohttp.ClientSession() as session:
         async with session.post(
                 f'{self.base_url}/account/authenticate/facebook', params=_params,
                 json=_data, headers=self.base_header) as resp:
             r = await resp.json()
             if resp.status != 200:
                 raise NakamaError(http_code=resp.status, error_name=r['error'], grpc_code=r['code'],
                                   message=r['message'])
             return NakamaSession(token=r['token'])
Ejemplo n.º 3
0
 async def authenticate_game_center(self, player_id: str, bundle_id: str, salt: str, signature: str,
                                    public_key_url: str, username: str, create_user: bool = True,
                                    timestamp_seconds: int = 0) -> NakamaSession:
     _data = {'player_id': player_id, 'bundle_id': bundle_id, 'timestamp_seconds': timestamp_seconds, 'salt': salt,
              'signature': signature, 'public_key_url': public_key_url}
     _params = {'create': str(create_user).lower(), 'username': username}
     async with aiohttp.ClientSession() as session:
         async with session.post(
                 f'{self.base_url}/account/authenticate/gamecenter', params=_params,
                 json=_data, headers=self.base_header) as resp:
             r = await resp.json()
             if resp.status != 200:
                 raise NakamaError(http_code=resp.status, error_name=r['error'], grpc_code=r['code'],
                                   message=r['message'])
             return NakamaSession(token=r['token'])