Пример #1
0
 def execute(self, service_request):
     try:
         return service_request.execute(http=self._http)
     except AccessTokenCredentialsError:
         self._google_auth.refresh_token(get_current_strategy())
         self._http = self._get_http(self._google_auth.access_token)
         return service_request.execute(http=self._http)
Пример #2
0
 def get_user(self, user_id):
     """
     Return user with given ID from the User model used by this backend.
     This is called by django.contrib.auth.middleware.
     """
     from social.strategies.utils import get_current_strategy
     strategy = self.strategy or get_current_strategy()
     return strategy.get_user(user_id)
Пример #3
0
 def get_user(self, user_id):
     """
     Return user with given ID from the User model used by this backend.
     This is called by django.contrib.auth.middleware.
     """
     from social.strategies.utils import get_current_strategy
     strategy = self.strategy or get_current_strategy()
     return strategy.get_user(user_id)
Пример #4
0
 def authenticate(self, *args, **kwargs):
     if 'username' in kwargs and 'password' in kwargs and self.strategy is None:
         self.strategy = get_current_strategy()
         if self.strategy:
             try:
                 return self.ml_authenticate(kwargs['username'],
                                             kwargs['password'])
             except (AuthFailed, HTTPError):
                 return None
     elif 'token' in kwargs and self.strategy is None:
         self.strategy = get_current_strategy()
         if self.strategy:
             try:
                 return self.ml_token_authenticate(kwargs['token'])
             except (AuthFailed, HTTPError):
                 return None
     else:
         return super(MLBackend, self).authenticate(*args, **kwargs)
Пример #5
0
 def authenticate(self, *args, **kwargs):
     if 'username' in kwargs and 'password' in kwargs and self.strategy is None:
         self.strategy = get_current_strategy()
         if self.strategy:
             try:
                 return self.ml_authenticate(
                     kwargs['username'], kwargs['password']
                 )
             except (AuthFailed, HTTPError):
                 return None
     elif 'token' in kwargs and self.strategy is None:
         self.strategy = get_current_strategy()
         if self.strategy:
             try:
                 return self.ml_token_authenticate(kwargs['token'])
             except (AuthFailed, HTTPError):
                 return None
     else:
         return super(MLBackend, self).authenticate(*args, **kwargs)
Пример #6
0
 def get_backend_instance(self, strategy=None):
     strategy = strategy or get_current_strategy()
     Backend = self.get_backend(strategy)
     if Backend:
         return Backend(strategy=strategy)
Пример #7
0
 def get_backend(self, strategy=None):
     strategy = strategy or get_current_strategy()
     if strategy:
         return get_backend(strategy.get_backends(), self.provider)