def auth(Req): Nonce = Req.REQUEST.get("nonce", None) if Nonce is None: return json_false500(Req) Sign = Req.META.get('HTTP_API_SIGN', None) if Sign is None: return json_false500(Req, {"description": "invalid_params", "key": "api_sign"}) PublicKey = Req.META.get('HTTP_PUBLIC_KEY', None) if PublicKey is None: return json_false500(Req, {"description": "invalid_params", "key": "public_key"}) try: Req.user = check_api_sign(PublicKey, Sign, Req.body) Cache = caching() Cache.set("nonce_" + PublicKey, int(Nonce), 50000) Nonce = Cache.get("nonce_" + PublicKey) return json_true(Req, {"nonce": Nonce, "public_key": PublicKey}) except: return json_false500(Req, {"description": "auth_faild"})