Пример #1
0
def api_upgrade_guest_user(player_guest, player_new):
    sign = encrypt_utils.u8_sign(
        encrypt_utils.GUEST_UPGRADE_STR.format(player_new.get_device_id(),
                                               player_guest.get_device_id2(),
                                               player_guest.get_device_id3(),
                                               player_guest.get_channel_uid(),
                                               player_guest.get_access_token(),
                                               player_new.get_channel_uid(),
                                               player_new.get_access_token(),
                                               config.PLATFORM,
                                               player_guest.get_uid()))
    data = '''{{"uid":"{}","extension1":"{{\\"uid\\":\\"{}\\",\\"access_token\\":\\"{}\\"}}","extension2":"{{\\"uid\\":\\"{}\\",\\"access_token\\":\\"{}\\"}}","platform":{},"deviceId":"{}","deviceId2":"{}","deviceId3":"{}","sign":"{}"}}'''.format(
        player_guest.get_uid(), player_guest.get_channel_uid(),
        player_guest.get_access_token(), player_new.get_channel_uid(),
        player_new.get_access_token(), config.PLATFORM,
        player_new.get_device_id(), player_guest.get_device_id2(),
        player_guest.get_device_id3(), sign)
    res = utils.post_to_as('/u8/user/upgradeGuestUser', data)
    code = int(res['result'])
    if code:
        panic('游客账号绑定失败: data={}, err_code={}'.format(data, code))
    player_guest.set_account(player_new.get_account())
    player_guest.set_password(player_new.get_password())
    logger.i('游客账号绑定成功: 账号:{}, 密码:{}, uid:{}'.format(
        player_guest.get_account(), player_guest.get_password(),
        player_guest.get_uid()))
    return
Пример #2
0
def api_get_token(player):
    sign = encrypt_utils.u8_sign(
        encrypt_utils.GET_TOKEN_SIGN_STR.format(config.APP_ID,
                                                config.CHANNEL_ID,
                                                player.get_device_id(),
                                                player.get_device_id2(),
                                                player.get_device_id3(),
                                                player.get_channel_uid(),
                                                player.get_access_token(),
                                                config.PLATFORM,
                                                config.SUB_CHANNEL,
                                                config.WORLD_ID))
    data = '''{{"appId":"{}","channelId":"{}","extension":"{{\\"uid\\":\\"{}\\",\\"access_token\\":\\"{}\\"}}","worldId":"{}","platform":{},"subChannel":"{}","deviceId":"{}","deviceId2":"{}","deviceId3":"{}","sign":"{}"}}'''.format(
        config.APP_ID, config.CHANNEL_ID, player.get_channel_uid(),
        player.get_access_token(), config.WORLD_ID, config.PLATFORM,
        config.SUB_CHANNEL, player.get_device_id(), player.get_device_id2(),
        player.get_device_id3(), sign)
    res = utils.post_to_as('/u8/user/getToken', data)
    code = int(res['result'])
    if code:
        panic('获取token失败: data={}, err_code={}'.format(data, code))
    player.set_uid(res['uid'])
    player.set_token(res['token'])
    player.save_account_info()
    logger.i('获取token成功: uid:{}, channel_uid:{}, token:{}'.format(
        res['uid'], res['channelUid'], res['token']))
    return res
Пример #3
0
def api_auth(player):
    sign = encrypt_utils.u8_sign(
        encrypt_utils.AUTH_SIGN_STR.format(player.get_access_token()))
    data = '{{"token":"{}","sign":"{}"}}'.format(player.get_access_token(),
                                                 sign)
    res = utils.post_to_as('/user/auth', data)
    player.set_channel_uid(res['uid'])
    logger.i('auth登录成功: channel_uid:{}'.format(res['uid']))
    return
Пример #4
0
def api_guest_login(player):
    sign = encrypt_utils.u8_sign(
        encrypt_utils.GUEST_LOGIN_SIGN_STR.format(player.get_device_id()))
    data = '{{"deviceId":"{}","sign":"{}"}}'.format(player.get_device_id(),
                                                    sign)
    res = utils.post_to_as('/user/guestLogin', data)
    code = int(res['result'])
    if code:
        panic('账号注册失败: data={}, err_code={}'.format(data, code))
    player.set_channel_uid(res['uid'])
    player.set_access_token(res['token'])
    logger.i('账号注册成功: deviceId:{}, channel_uid:{}, access_token:{}'.format(
        player.get_device_id(), res['uid'], res['token']))
    # 返回新注册账号的信息
    return res
Пример #5
0
def api_as_login(player):
    sign = encrypt_utils.u8_sign(
        encrypt_utils.LOGIN_SIGN_STR.format(player.get_account(),
                                            player.get_device_id(),
                                            player.get_password(),
                                            config.PLATFORM))
    data = '{{"account":"{}","password":"******","deviceId":"{}","platform":{},"sign":"{}"}}'.format(
        player.get_account(), player.get_password(), player.get_device_id(),
        config.PLATFORM, sign)
    res = utils.post_to_as('/user/login', data)
    code = int(res['result'])
    if code:
        panic('账号密码登录失败: data={}, err_code={}'.format(data, code))
    player.set_channel_uid(res['uid'])
    player.set_access_token(res['token'])
    logger.i(
        '账号密码登录成功: 账号:{}, 密码:{}, deviceId:{}, channel_uid:{}, access_token:{}'.
        format(player.get_account(), player.get_password(),
               player.get_device_id(), res['uid'], res['token']))
    return