def _get_project_key(self, request): dsn = request.GET.get('dsn') try: key = ProjectKey.from_dsn(dsn) except ProjectKey.DoesNotExist: return return key
def _get_project_key(self, request): try: dsn = request.GET['dsn'] except KeyError: return try: key = ProjectKey.from_dsn(dsn) except ProjectKey.DoesNotExist: return return key
def authenticate_credentials(self, token): try: key = ProjectKey.from_dsn(token) except ProjectKey.DoesNotExist: raise AuthenticationFailed('Invalid token') if not key.is_active: raise AuthenticationFailed('Invalid token') with configure_scope() as scope: scope.set_tag("api_token_type", self.token_name) scope.set_tag("api_project_key", key.id) return (AnonymousUser(), key)
def authenticate_credentials(self, token): from django.contrib.auth.models import AnonymousUser # Django 1.9 setup issue from sentry.models import ProjectKey # Django 1.9 setup issue try: key = ProjectKey.from_dsn(token) except ProjectKey.DoesNotExist: raise AuthenticationFailed('Invalid token') if not key.is_active: raise AuthenticationFailed('Invalid token') with configure_scope() as scope: scope.set_tag("api_token_type", self.token_name) scope.set_tag("api_project_key", key.id) return (AnonymousUser(), key)