degubowanie
All checks were successful
continuous-integration/drone Build is passing

This commit is contained in:
Jakub K 2024-01-22 22:46:54 +01:00
parent 176f3eea6f
commit c9dde8d76b

View File

@ -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())