I'm able to authenticate against some RESTful API with one of the following methods:
- password
- certificate
- anonymous
I've created AuthenticationBase class and its subclassess:
- PasswordAuthentication
- CertificateAuthentication
- AnonymousAuthentication
Basically authentication take two steps:
- get_rsts_token
- set_access_token - You need RSTS token first
set_access_token has the same implementation across subclasses but get_rsts_token differs so I've tried something like this:
import abc
ABC = abc.ABCMeta('ABC', (object,), {'__slots__': ()})
class AuthenticationBase(ABC):
@abc.abstractmethod
def get_rsts_token(self):
pass
def set_access_token()
rsts_token = self.get_rsts_token()
access_token = retrieve_token(rsts_token)
but it leads to an error:
TypeError: Can't instantiate abstract class AuthenticationBase with abstract methods get_rsts_token
I wish to avoid rewriting set_access_token in all subclasses. How to achieve this?