Пример #1
0
    def device_token(self):
        challenge = self.challenge()

        data = b64decode(challenge["data"])

        req = HTTPRequest.post("/v6/device_auth_token")
        req.form["challenge"] = challenge["challenge"]
        req.form["client_id"] = "%016x" % self.client_id
        if self.region == 2:
            req.form["ist"] = "true"
        else:
            req.form["ist"] = "false"
        req.form["key_generation"] = self.key_generation
        req.form["system_version"] = self.system_digest
        req.form["mac"] = self.calculate_mac(req.form.encode(), data)

        response = self.request(req)
        return response.json
Пример #2
0
	async def device_token(self, client_id):
		challenge = await self.challenge()
		
		data = switch.b64decode(challenge["data"])
		
		req = http.HTTPRequest.post("/v6/device_auth_token")
		req.plainform["challenge"] = challenge["challenge"]
		req.plainform["client_id"] = "%016x" %client_id
		if self.region == 2:
			req.plainform["ist"] = "true"
		else:
			req.plainform["ist"] = "false"
		req.plainform["key_generation"] = self.key_generation
		req.plainform["system_version"] = self.system_digest
		
		string = http.formencode(req.plainform, False)
		req.plainform["mac"] = self.calculate_mac(string, data)
		
		response = await self.request(req)
		return response.json
Пример #3
0
    async def device_token(self, client_id):
        challenge = await self.challenge()

        data = switch.b64decode(challenge["data"])

        req = http.HTTPRequest.post("/v%i/device_auth_token" %
                                    self.api_version)
        req.rawform = {
            "challenge": challenge["challenge"],
            "client_id": "%016x" % client_id,
            "ist": "true" if self.region == 2 else "false",
            "key_generation": self.key_generation,
            "system_version": self.system_digest
        }

        string = http.formencode(req.rawform, False)
        req.rawform["mac"] = self.calculate_mac(string, data)

        response = await self.request(req)
        return response.json
Пример #4
0
def test_b64decode():
    assert switch.b64decode("_v_-_w") == b"\xFE\xFF\xFE\xFF"