Untitled

 avatar
user_0623289
python
2 months ago
2.2 kB
16
Indexable
Never
    def verify(self, email: str, code: str,dev:str,key=None):
        data ={
            "validationContext": {
                "type": 1,
                "identity": email,
                "data": {"code": code}},
            "deviceID": dev,
            #"timestamp": int(timestamp() * 1000)
        }
        if key:
          data["verifyInfoKey"]=key
        data=json.dumps(data)

        response = requests.post(f"{self.api}/g/s/auth/check-security-validation", headers=self.parse_headers(data=data), data=data, proxies=self.proxies, verify=self.certificatePath)
        response = requests.post(f"{self.api}/g/s/auth/verify-account", headers=self.parse_headers(data=data), data=data, proxies=self.proxies, verify=self.certificatePath)
        if response.status_code != 200: return exceptions.CheckException(json.loads(response.text))
        else: return response.status_code
    def request_verify_code(self, dev: str,email: str, resetPassword: bool = False,key=None):
        """
        Request an verification code to the targeted email.

        **Parameters**
            - **email** : Email of the account.
            - **resetPassword** : If the code should be for Password Reset.

        **Returns**
            - **Success** : 200 (int)

            - **Fail** : :meth:`Exceptions <amino.lib.util.exceptions>`
        """
        data = {
            "identity": email,
            "type": 1,
            "deviceID": dev
        }

        if key:
          data["verifyInfoKey"]=key       

        if resetPassword is True:
            data["level"] = 2
            data["purpose"] = "reset-password"

        data = json.dumps(data)
        
        headd=self.parse_headers(data=data)
        headd["NDCAUTH"]=None
        response = requests.post(f"{self.api}/g/s/auth/request-security-validation", headers=headd, data=data, proxies=self.proxies, verify=self.certificatePath)
        #print(self.parse_headers(deviceId=dev,data=data))
        if response.status_code != 200: return exceptions.CheckException(json.loads(response.text))
        else: return response.status_code
Leave a Comment