def authenticate_credentials(self, key):
        try:
            token = self.model.objects.select_related('user').get(key=key)
        except self.model.DoesNotExist:
            raise exceptions.AuthenticationFailed(_('Invalid token.'))

        if not token.user.is_active:
            raise exceptions.AuthenticationFailed(_('User inactive or deleted.'))

        if token.created < timezone.now() - timezone.timedelta(hours=1):
            raise exceptions.AuthenticationFailed(_('Token has expired.'))
        else:
            token.created = timezone.now()
            token.save()

        return token.user, token
dataset/ETHPy150Open opennode/nodeconductor/nodeconductor/core/authentication.py/TokenAuthentication.authenticate_credentials/original