Define a simple base class interface in AuthorizationToken:
class AuthorizationToken():
"""
Base class with simple interface
"""
def __init__(self, provider):
# establish the session via this implementation
@classmethod
def can_auth(cls, provider):
# can this implementation be used for the provider?
Create a new subclass of AuthorizationToken with __init__ and can_auth to implement a new auth type.
No further changes are needed in ProviderClient; a provider is checked against each subclass in turn (including AuthorizationToken itself) until a supported implementation is found.
Define a simple base class interface in
AuthorizationToken
:Create a new subclass of
AuthorizationToken
with__init__
andcan_auth
to implement a new auth type.No further changes are needed in
ProviderClient
; a provider is checked against each subclass in turn (includingAuthorizationToken
itself) until a supported implementation is found.