def get_user(self, access_token): request_url = self._get_url() # This is a special case client, # because auth_token is not set yet (this is how we verify it) # So do not use the shared base client for this! response = requests.get(request_url, headers={"Authorization": "Bearer {}".format(access_token)}) # TODO: replace with self.get(...) try: user_dict = response.json() response.raise_for_status() except Exception: if response.status_code == 401: raise AuthenticationError( request_url, response, "Invalid Token.\nSee http://docs.polyaxon.com/faqs/authentication/ for help", 401) raise AuthenticationError( request_url, response, "Login failed.\nSee http://docs.polyaxon.com/faqs/authentication/ for help", response.status_code) return UserConfig.from_dict(user_dict)
def test_project_config(self): config_dict = { 'username': '******', 'uid': 'sdfsdf098sdf80s9dSDF800', 'email': '*****@*****.**' } config = UserConfig.from_dict(config_dict) assert config.to_dict() == config_dict
def get_user(self, token=None): token = token or self.token request_url = self._get_http_url() response = self.get(request_url, headers={ "Authorization": "{} {}".format(self.authentication_type, token) }) try: user_dict = response.json() response.raise_for_status() except Exception: if response.status_code == 401: raise AuthenticationError( request_url, response, "Invalid Token.\nSee http://docs.polyaxon.com/faqs/authentication/ for help", 401) raise AuthenticationError( request_url, response, "Login failed.\nSee http://docs.polyaxon.com/faqs/authentication/ for help", response.status_code) return UserConfig.from_dict(user_dict)
def test_user_config(self): config_dict = {'username': '******', 'email': '*****@*****.**'} config = UserConfig.from_dict(config_dict) assert config.to_dict() == config_dict