From c9dde8d76b8fa36de425c078d545dc5e3d775837 Mon Sep 17 00:00:00 2001 From: Jakub K Date: Mon, 22 Jan 2024 22:46:54 +0100 Subject: [PATCH] degubowanie --- jobposting/views.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/jobposting/views.py b/jobposting/views.py index 6d362be..df202f0 100644 --- a/jobposting/views.py +++ b/jobposting/views.py @@ -9,6 +9,7 @@ from .auth import OAuth2ClientCredentialAuthentication from rest_framework.views import APIView import requests from django.conf import settings +import base64 from jobposting.serializers import ( JobListingSerializer, @@ -97,7 +98,13 @@ class GetAuthTokenView(APIView): client_id = settings.REACT_CLIENT_ID client_secret = settings.REACT_CLIENT_SECRET print("GET SECRET") - headers = {'Content-Type': 'application/x-www-form-urlencoded'} + credential = "{0}:{1}".format(client_id, client_secret) + base64.b64encode(credential.encode("utf-8")) + + headers = {'Content-Type': 'application/x-www-form-urlencoded', + 'Authorization': 'Basic '+credential, + 'Cache-Control': 'no-cache' + } data = { "grant_type": "client_credentials", "client_id": client_id, @@ -105,5 +112,5 @@ class GetAuthTokenView(APIView): "redirect_uri": "http://izaac.izaac.pl/noexist/callback" } print("DATA READY") - response = requests.post('http://izaac.izaac.pl/o/token/', data=data, headers=headers) + response = requests.post('http://izaac.izaac.pl/o/token/'+"grant_type=client_credentials", headers=headers) return Response(response.json()) \ No newline at end of file