Exemplo n.º 1
0
    def sendData(self, username: str, message: str):
        """ 
        Enable Custom Logs.
        ```
        from AuthGG.logging import Logging
        client = Loggging(aid='', apikey='', secret='')
        try:
            client.sendData(username='******', message='Deleted User')
        except:
            pass   
        ```
        """

        data = {
            "type": "log",
            "action": message,
            "pcuser": socket.gethostname(),
            "username": username,
            "aid": self.aid,
            "secret": self.secret,
            "apikey": self.apikey
        }
        r = requests.post(f"https://api.auth.gg/v1/", data=data)
        response = r.json()
        if response['result'] == "success":
            return True
        else:
            raise error_handler.ErrorConnecting()
Exemplo n.º 2
0
    def register(self, license_key: str, email:str, username: str, password: str):
        """
        Easily register users
        ```
        from AuthGG.client import Client

        client = Client(api_key="api_key", aid="aid", application_secret="secret")

        email = input("Email: ")
        license_key = input("License: ")
        username = input("Username: "******"Password: "******"""

        hwid = str(subprocess.check_output('wmic csproduct get uuid')).split('\\r\\n')[1].strip('\\r').strip()         
        data = {
            "type": "register",
            "secret": self.application_secret,
            "apikey": self.api_key,
            "aid": self.aid,
            "username": username,
            "password": password,
            "hwid": hwid,
            "email": email,
            "license": license_key
        }       
        headers = {
            "Content-Type": "application/x-www-form-urlencoded"
        }
        r = requests.post("https://api.auth.gg/v1/", data=data, headers=headers)        
        response = r.json()["result"]
        if response == "success":
            return True
        elif response == "invalid_license":
            raise error_handler.InvalidLicense()
        elif response == "email_used":
            raise error_handler.UserError(message="email_used")
        elif response == "invalid_username":
            raise error_handler.UserError(message="invalid_username")               
        else:
            raise error_handler.ErrorConnecting()         
Exemplo n.º 3
0
    def login(self, username: str, password: str):
        """
        Allow the user to login
        ```
        client = Client(api_key="api_key", aid="aid", application_secret="secret")

        username = input("Username: "******"Password: "******"""

        hwid = str(subprocess.check_output('wmic csproduct get uuid')).split('\\r\\n')[1].strip('\\r').strip()        
        data = {
            "type": "login",
            "secret": self.application_secret,
            "apikey": self.api_key,
            "aid": self.aid,
            "username": username,
            "password": password,
            "hwid": hwid
        }
        headers = {
            "Content-Type": "application/x-www-form-urlencoded"
        }
        r = requests.post("https://api.auth.gg/v1/", data=data, headers=headers)
        response = r.json()
        if response["result"] == "success":
            return True
        elif response["result"] == "invalid_details":
            raise error_handler.InvalidPassword()
        elif response["result"] == "invalid_hwid":
            raise error_handler.InvalidHWID()
        elif response["result"] == "time_expired":
            raise error_handler.SubscriptionExpired()
        elif response["result"] == "hwid_updated":
            return True
        else:
            raise error_handler.ErrorConnecting()
Exemplo n.º 4
0
    def changePassword(self, username: str, password: str, newPassword: str):
        """
        Changes the password for that user.
        ```
        from AuthGG.client import Client

        client = Client(api_key="api_key", aid="aid", application_secret="secret")

        username = input("Username: "******"Password: "******"New Password: "******"""

        data = {
            "type": "changepw",
            "secret": self.application_secret,
            "apikey": self.api_key,
            "aid": self.aid,
            "username": username,
            "password": password,
            "newpassword": newPassword
        }           
        headers = {
            "Content-Type": "application/x-www-form-urlencoded"
        }
        r = requests.post("https://api.auth.gg/v1/", data=data, headers=headers)       
        response = r.json()["response"]
        if response == "success":
            return True
        elif response == "invalid_details":
            raise error_handler.UserError(message="invalid_details")
        else:
            raise error_handler.ErrorConnecting()
Exemplo n.º 5
0
    def forgotPassword(self, username: str):
        """
        Sends a reset password email to the given user
        ```
        from AuthGG.client import Client

        client = Client(api_key="api_key", aid="aid", application_secret="secret")

        username = input("Username: "******"""

        data = {
            "type": "forgotpw",
            "secret": self.application_secret,
            "apikey": self.api_key,
            "aid": self.aid,
            "username": username
        }           
        headers = {
            "Content-Type": "application/x-www-form-urlencoded"
        }
        r = requests.post("https://api.auth.gg/v1/", data=data, headers=headers)        
        response = r.json()["result"]  
        info = r.json()["info"]      
        if response == "success":
            return True
        elif response == "failed":
            return f"{info}"
        else:
            raise error_handler.ErrorConnecting()
Exemplo n.º 6
0
    def getUserCount(self):
        """
        Get the user count of your application
        ```
        from AuthGG.admin import AdminClient

        client = AdminClient("authorization_key")

        try:
            status = client.getUserCount()
            print(status)
        except Exception as e:
            print(e)        
        ```
        """
        r = requests.get(
            f"https://developers.auth.gg/USERS/?type=count&authorization={self.authorization}"
        )
        if r.json()['status'] == "success":
            jsonResponse = r.json()["value"]
            return jsonResponse
        else:
            raise error_handler.ErrorConnecting()