sources/oauth: separate clients into separate modules
This commit is contained in:
		@ -1,7 +1,9 @@
 | 
			
		||||
"""OAuth Base views"""
 | 
			
		||||
from typing import Callable, Optional
 | 
			
		||||
from typing import Optional, Type
 | 
			
		||||
 | 
			
		||||
from passbook.sources.oauth.clients import BaseOAuthClient, get_client
 | 
			
		||||
from passbook.sources.oauth.clients.base import BaseOAuthClient
 | 
			
		||||
from passbook.sources.oauth.clients.oauth1 import OAuthClient
 | 
			
		||||
from passbook.sources.oauth.clients.oauth2 import OAuth2Client
 | 
			
		||||
from passbook.sources.oauth.models import OAuthSource
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -9,11 +11,13 @@ from passbook.sources.oauth.models import OAuthSource
 | 
			
		||||
class OAuthClientMixin:
 | 
			
		||||
    "Mixin for getting OAuth client for a source."
 | 
			
		||||
 | 
			
		||||
    client_class: Optional[Callable] = None
 | 
			
		||||
    client_class: Optional[Type[BaseOAuthClient]] = None
 | 
			
		||||
 | 
			
		||||
    def get_client(self, source: OAuthSource) -> BaseOAuthClient:
 | 
			
		||||
        "Get instance of the OAuth client for this source."
 | 
			
		||||
        if self.client_class is not None:
 | 
			
		||||
            # pylint: disable=not-callable
 | 
			
		||||
            return self.client_class(source)
 | 
			
		||||
        return get_client(source)
 | 
			
		||||
        if source.request_token_url:
 | 
			
		||||
            return OAuthClient(source)
 | 
			
		||||
        return OAuth2Client(source)
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user