This commit is contained in:
parent
176f3eea6f
commit
c9dde8d76b
@ -9,6 +9,7 @@ from .auth import OAuth2ClientCredentialAuthentication
|
|||||||
from rest_framework.views import APIView
|
from rest_framework.views import APIView
|
||||||
import requests
|
import requests
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
import base64
|
||||||
|
|
||||||
from jobposting.serializers import (
|
from jobposting.serializers import (
|
||||||
JobListingSerializer,
|
JobListingSerializer,
|
||||||
@ -97,7 +98,13 @@ class GetAuthTokenView(APIView):
|
|||||||
client_id = settings.REACT_CLIENT_ID
|
client_id = settings.REACT_CLIENT_ID
|
||||||
client_secret = settings.REACT_CLIENT_SECRET
|
client_secret = settings.REACT_CLIENT_SECRET
|
||||||
print("GET 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 = {
|
data = {
|
||||||
"grant_type": "client_credentials",
|
"grant_type": "client_credentials",
|
||||||
"client_id": client_id,
|
"client_id": client_id,
|
||||||
@ -105,5 +112,5 @@ class GetAuthTokenView(APIView):
|
|||||||
"redirect_uri": "http://izaac.izaac.pl/noexist/callback"
|
"redirect_uri": "http://izaac.izaac.pl/noexist/callback"
|
||||||
}
|
}
|
||||||
print("DATA READY")
|
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())
|
return Response(response.json())
|
||||||
Loading…
x
Reference in New Issue
Block a user