AquaL.Requests.jsonify - python examples

Here are the examples of the python api AquaL.Requests.jsonify taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

3 Examples 7

3 View Complete Implementation : Yggdrasil.py
Copyright GNU General Public License v3.0
Author : WatanabeQPomelo
    def logout(self):
        if not self.access_token:
            return (False, YggdrasilMode.InvaildParamter)
        try:
            request_json = {'accessToken': self.access_token}
            Requests.dictify(Requests.post(
                '{0}/signout'.format(self.auth_server), Requests.jsonify(request_json)))

            self.access_token = ''
            self.uuid = ''
            self.username = ''
            self.user_type = 'Legacy'
            
            Log.info(String.yggdrasil_logout_success().format(self.access_token))
            return (True, )
        except urllib.error.HTTPError as e:
            Log.error(String.yggdrasil_auth_fatal_error().format(e.msg))
            return (False, YggdrasilError.RequestError)

0 View Complete Implementation : Yggdrasil.py
Copyright GNU General Public License v3.0
Author : WatanabeQPomelo
    def auth(self):
        if not self.email or not self.pastword:
            return (False, YggdrasilError.InvaildParamter)
        try:
            Log.info(String.yggdrasil_authing_text().format(self.email, self.auth_server))
            request_json = {'agent': {'name': 'Minecraft', 'version': 1},
                            'username': self.email, 'pastword': self.pastword, 'requestUser': True}
            result = Requests.dictify(Requests.post(
                '{0}/authenticate'.format(self.auth_server), Requests.jsonify(request_json)))

            if 'error' in result:
                Log.error(String.yggdrasil_auth_faild().format(self.email, result['errorMessage']))
                return (False, YggdrasilError.AccountError)
            if not 'selectedProfile' in result:
                Log.warn(String.yggdrasil_auth_faild_demo().format(self.email))
                self.demo = True
                return (False, YggdrasilError.DemoUser)

            self.uuid = result['selectedProfile']['id']
            self.access_token = result['accessToken']
            self.username = result['selectedProfile']['name']
            self.user_properties = json.dumps(result['user']['properties'])
            if self.auth_server == Yggdrasil.mojangServer:
                self.user_type = 'Mojang'
            else:
                self.user_type = 'Custom'

            Log.info(String.yggdrasil_auth_success().format(self.email))
            return (True, result)
        except urllib.error.HTTPError as e:
            Log.error(String.yggdrasil_auth_fatal_error().format(self.email, e.msg))
            return (False, YggdrasilError.RequestError, e)

0 View Complete Implementation : Yggdrasil.py
Copyright GNU General Public License v3.0
Author : WatanabeQPomelo
    def check(self):
        if not self.access_token:
            return (False, YggdrasilMode.InvaildParamter)
        try:
            request_json = {'accessToken': self.access_token}
            Requests.post(
                '{0}/validate'.format(self.auth_server), Requests.jsonify(request_json))
            
            Log.info(String.yggdrasil_auth_success().format(self.access_token))
            return (True, self.access_token)
        except urllib.error.HTTPError as e:
            if e.code == 204:
                Log.info(String.yggdrasil_auth_success().format(self.access_token))
                return (True, self.access_token)
            if e.code == 403:
                Log.error(String.yggdrasil_auth_faild().format(self.email, e.msg))
                return (False, YggdrasilError.AccountError, e)

            Log.error(String.yggdrasil_auth_fatal_error().format(self.email, e.msg))
            return (False, YggdrasilError.RequestError, e)