def login(self, user, password): request_data = {"password": password} if re.match( r"^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", user, ): request_data["user"] = user else: request_data["username"] = user login_request = requests.post( self.server_url + self.API_path + "login", data=request_data, verify=self.ssl_verify, proxies=self.proxies, cert=self.cert, ) if login_request.status_code == 401: raise RocketAuthenticationException() if (login_request.status_code == 200 and login_request.json().get("status") == "success"): self.headers["X-Auth-Token"] = ( login_request.json().get("data").get("authToken")) self.headers["X-User-Id"] = login_request.json().get("data").get( "userId") return login_request raise RocketConnectionException()
def login(self, user, password): request_data = {'password': password} if re.match( '^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$', user): request_data['user'] = user else: request_data['username'] = user login_request = requests.post(self.server_url + self.API_path + 'login', data=request_data, verify=self.ssl_verify, proxies=self.proxies) if login_request.status_code == 401: raise RocketAuthenticationException() if login_request.status_code == 200: if login_request.json().get('status') == "success": self.headers['X-Auth-Token'] = login_request.json().get( 'data').get('authToken') self.headers['X-User-Id'] = login_request.json().get( 'data').get('userId') return login_request else: raise RocketAuthenticationException() else: raise RocketConnectionException()
def login(self, user, password): login_request = requests.post(self.server_url + self.API_path + 'login', data={'username': user, 'password': password}, verify=self.ssl_verify, proxies=self.proxies) if login_request.status_code == 401: raise RocketAuthenticationException() if login_request.status_code == 200: if login_request.json().get('status') == "success": self.headers['X-Auth-Token'] = login_request.json().get('data').get('authToken') self.headers['X-User-Id'] = login_request.json().get('data').get('userId') return login_request else: raise RocketAuthenticationException() else: raise RocketConnectionException()