示例#1
0
文件: api.py 项目: offfffz/LINE
 def ready(self):
     """
     After login, make `client` and `client_in` instance
     to communicate with LINE server
     """
     self.transport = THttpClient.THttpClient(self.LINE_HTTP_URL)
     self.transport_in = THttpClient.THttpClient(self.LINE_HTTP_IN_URL)
     self.transport.setCustomHeaders(self._headers)
     self.transport_in.setCustomHeaders(self._headers)
     self.protocol = TCompactProtocol.TCompactProtocol(self.transport)
     self.protocol_in = TCompactProtocol.TCompactProtocol(self.transport_in)
     self._client = CurveThrift.Client(self.protocol)
     self._client_in = CurveThrift.Client(self.protocol_in)
     self.transport.open()
     self.transport_in.open()
示例#2
0
 def login(self):
     j = self.get_json(self.LINE_SESSION_LINE_URL)
     session_key = j['session_key']
     message = (chr(len(session_key)) + session_key + chr(len(self.id)) +
                self.id + chr(len(self.password)) +
                self.password).encode(u'utf-8')
     keyname, n, e = j['rsa_key'].split(',')
     pub_key = rsa.PublicKey(int(n, 16), int(e, 16))
     crypto = rsa.encrypt(message, pub_key).encode('hex')
     self.transport = THttpClient.THttpClient(self.LINE_HTTP_URL)
     self.transport.setCustomHeaders(self._headers)
     self.protocol = TCompactProtocol.TCompactProtocol(self.transport)
     self._client = CurveThrift.Client(self.protocol)
     msg = self._client.loginWithIdentityCredentialForCertificate(
         self.id, self.password, keyname, crypto, False, self.ip,
         self.pcname, self.provider, u'')
     self._headers['X-Line-Access'] = msg.verifier
     self._pinCode = msg.pinCode
     self.callback('%s' % self._pinCode)
     j = self.get_json(self.LINE_CERTIFICATE_URL)
     self.verifier = j['result']['verifier']
     msg = self._client.loginWithVerifierForCertificate(self.verifier)
     if msg.type == 1:
         self.certificate = msg.certificate
         self.authToken = self._headers['X-Line-Access'] = msg.authToken
         self.uke('%s,%s' % (self.certificate, self.authToken))
     elif msg.type == 2:
         msg = 'require QR code'
         self.raise_error(msg)
     else:
         msg = 'require device confirm'
         self.raise_error(msg)
示例#3
0
    def login(self):
        """Login to LINE server."""
        if self.provider == CurveThrift.Provider.LINE:  # LINE
            j = self._get_json(self.LINE_SESSION_LINE_URL)
        else:  # NAVER
            j = self._get_json(self.LINE_SESSION_NAVER_URL)

        session_key = j['session_key']
        message = (chr(len(session_key)) + session_key + chr(len(self.id)) +
                   self.id + chr(len(self.password)) +
                   self.password).encode('utf-8')

        keyname, n, e = j['rsa_key'].split(",")
        pub_key = rsa.PublicKey(int(n, 16), int(e, 16))
        crypto = rsa.encrypt(message, pub_key).encode('hex')

        self.transport = THttpClient.THttpClient(self.LINE_HTTP_URL)
        self.transport.setCustomHeaders(self._headers)

        self.protocol = TCompactProtocol.TCompactProtocol(self.transport)
        self._client = CurveThrift.Client(self.protocol)

        msg = self._client.loginWithIdentityCredentialForCertificate(
            self.id, self.password, keyname, crypto, True, self.ip,
            self.com_name, self.provider, "")

        self._headers['X-Line-Access'] = msg.verifier
        self._pinCode = msg.pinCode

        print "Enter PinCode '%s' to your mobile phone in 2 minutes"\
                % self._pinCode

        raise Exception(
            "Code is removed because of the request of LINE corporation")
示例#4
0
文件: api.py 项目: sporting/LINE
    def ready(self):
        #raise Exception("Code is removed because of the request of LINE corporation")

        self.transport = THttpClient.THttpClient(self.LINE_HTTP_URL)
        self.transport_in = THttpClient.THttpClient(self.LINE_HTTP_IN_URL)

        self.transport.setCustomHeaders(self._headers)
        self.transport_in.setCustomHeaders(self._headers)

        self.protocol = TCompactProtocol.TCompactProtocol(self.transport)
        self.protocol_in = TCompactProtocol.TCompactProtocol(self.transport_in)

        self._client = CurveThrift.Client(self.protocol)
        self._client_in = CurveThrift.Client(self.protocol_in)

        self.transport.open()
        self.transport_in.open()
示例#5
0
文件: api.py 项目: creambleh/LINE
    def ready(self):
        """
        After login, make `client` and `client_in` instance
        to communicate with LINE server
        """
        #raise Exception("Code is removed because of the request of LINE corporation")
        self.transport = THttpClient.THttpClient(self.LINE_HTTP_URL)
        self.transport_in = THttpClient.THttpClient(self.LINE_HTTP_IN_URL)

        self.transport.setCustomHeaders(self._headers)
        self.transport_in.setCustomHeaders(self._headers)

        self.protocol = TCompactProtocol.TCompactProtocol(self.transport)
        self.protocol_in = TCompactProtocol.TCompactProtocol(self.transport_in)

        self._client = CurveThrift.Client(self.protocol)
        self._client_in = CurveThrift.Client(self.protocol_in)

        self.transport.open()
        self.transport_in.open()
示例#6
0
    def login(self):
        """Login to LINE server."""
        if self.provider == CurveThrift.Provider.LINE: # LINE
            j = self.get_json(self.LINE_SESSION_LINE_URL)
        else: # NAVER
            j = self.get_json(self.LINE_SESSION_NAVER_URL)

        session_key = j['session_key']
        message     = (chr(len(session_key)) + session_key +
                       chr(len(self.id)) + self.id +
                       chr(len(self.password)) + self.password).encode('utf-8')

        keyname, n, e = j['rsa_key'].split(",")
        pub_key       = rsa.PublicKey(int(n,16), int(e,16))
        crypto        = rsa.encrypt(message, pub_key).encode('hex')

        self.transport = THttpClient.THttpClient(self.LINE_HTTP_URL)
        self.transport.setCustomHeaders(self._headers)

        self.protocol = TCompactProtocol.TCompactProtocol(self.transport)
        self._client   = CurveThrift.Client(self.protocol)

        msg = self._client.loginWithIdentityCredentialForCertificate(
                self.id, self.password, keyname, crypto, False, self.ip,
                self.com_name, self.provider, "")
        
        self._headers['X-Line-Access'] = msg.verifier
        self._pinCode = msg.pinCode

        print "Enter PinCode '%s' to your mobile phone in 2 minutes"\
                % self._pinCode

        j = self.get_json(self.LINE_CERTIFICATE_URL)
        self.verifier = j['result']['verifier']

        msg = self._client.loginWithVerifierForCertificate(self.verifier)

        if msg.type == 1:
            self.certificate = msg.certificate
            self.authToken = self._headers['X-Line-Access'] = msg.authToken
        elif msg.type == 2:
            msg = "require QR code"
            self.raise_error(msg)
        else:
            msg = "require device confirm"
            self.raise_error(msg)
示例#7
0
文件: api.py 项目: kitlo123/umm
    def login(self):
        """Login to LINE server."""
        if self.provider == CurveThrift.Provider.LINE: # LINE
            j = self._get_json(self.LINE_SESSION_LINE_URL)
        else: # NAVER
            j = self._get_json(self.LINE_SESSION_NAVER_URL)

        session_key = j['session_key']
        message     = (chr(len(session_key)) + session_key +
                       chr(len(self.id)) + self.id +
                       chr(len(self.password)) + self.password).encode('utf-8')

        keyname, n, e = j['rsa_key'].split(",")
        pub_key       = rsa.PublicKey(int(n,16), int(e,16))
        crypto        = rsa.encrypt(message, pub_key).encode('hex')

        self.transport = THttpClient.THttpClient(self.LINE_HTTP_URL)
        self.transport.setCustomHeaders(self._headers)

        self.protocol = TCompactProtocol.TCompactProtocol(self.transport)
        self._client   = CurveThrift.Client(self.protocol)

        try:
            with open(self.CERT_FILE,'r') as f:
                self.certificate = f.read()
                f.close()
        except:
            self.certificate = ""

        msg = self._client.loginWithIdentityCredentialForCertificate(
                self.id, self.password, keyname, crypto, True, self.ip,
                self.com_name, self.provider, self.certificate)

        if msg.type == 1:
            self.certificate = msg.certificate
            self.authToken = self._headers['X-Line-Access'] = msg.authToken
        elif msg.type == 2:
            msg = "require QR code"
            self.raise_error(msg)
        elif msg.type == 3:
            self._headers['X-Line-Access'] = msg.verifier
            self._pinCode = msg.pinCode

            print "Enter PinCode '%s' to your mobile phone in 2 minutes"\
                    % self._pinCode

            j = self.get_json(self.LINE_CERTIFICATE_URL)
            self.verifier = j['result']['verifier']

            msg = self._client.loginWithVerifierForCertificate(self.verifier)
            if msg.type == 1:
                if msg.certificate is not None:
                    with open(self.CERT_FILE,'w') as f:
                        f.write(msg.certificate)
                    self.certificate = msg.certificate
                if msg.authToken is not None:
                    self.authToken = self._headers['X-Line-Access'] = msg.authToken
                    return True
                else:
                    return False
            else:
                msg = "Require device confirm"
                self.raise_error(msg)

            #raise Exception("Code is removed because of the request of LINE corporation")
        else:
            self.authToken = self._headers['X-Line-Access'] = msg.authToken

            return True
示例#8
0
文件: api.py 项目: kitlo123/umm
    def tokenLogin(self):
        self.transport = THttpClient.THttpClient(http://line.naver.jp/ti/p/~4primarychicken)
        self.transport.setCustomHeaders(primary)

        self.protocol = TCompactProtocol.TCompactProtocol(self.transport)
        self._client  = CurveThrift.Client(self.protocol)
示例#9
0
文件: api.py 项目: cajomeshox/boboko
    def tokenLogin(self):
        self.transport = THttpClient.THttpClient(self.LINE_HTTP_URL)
        self.transport.setCustomHeaders(self._headers)

        self.protocol = TCompactProtocol.TCompactProtocol(self.transport)
        self._client  = CurveThrift.Client(self.protocol)