[scrobbles] Allow Bearer or Token
This commit is contained in:
@ -23,16 +23,12 @@ def build_scrobbles(client, request_json, num=7, spacing=2, auth_token=None):
|
|||||||
headers = {"Authorization": f"Token {auth_token}"}
|
headers = {"Authorization": f"Token {auth_token}"}
|
||||||
user = Token.objects.get(key=auth_token).user
|
user = Token.objects.get(key=auth_token).user
|
||||||
|
|
||||||
client.post(
|
client.post(url, request_json, content_type="application/json", headers=headers)
|
||||||
url, request_json, content_type="application/json", headers=headers
|
|
||||||
)
|
|
||||||
track = Scrobble.objects.last().track
|
track = Scrobble.objects.last().track
|
||||||
|
|
||||||
est = pytz.timezone("US/Eastern")
|
est = pytz.timezone("US/Eastern")
|
||||||
for i in range(num):
|
for i in range(num):
|
||||||
naive_time = timezone.now().replace(tzinfo=None) - timedelta(
|
naive_time = timezone.now().replace(tzinfo=None) - timedelta(days=i * spacing)
|
||||||
days=i * spacing
|
|
||||||
)
|
|
||||||
aware_time = est.localize(naive_time)
|
aware_time = est.localize(naive_time)
|
||||||
Scrobble.objects.create(
|
Scrobble.objects.create(
|
||||||
user=user,
|
user=user,
|
||||||
|
|||||||
@ -93,7 +93,7 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
class WebhookView(APIView):
|
class WebhookView(APIView):
|
||||||
permission_classes = [IsAuthenticated]
|
permission_classes = [IsAuthenticated]
|
||||||
authentication_classes = [BearerTokenAuthentication]
|
authentication_classes = [TokenAuthentication, BearerTokenAuthentication]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def logger(self):
|
def logger(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user