przekazanie do sekretów do env - test only

This commit is contained in:
Jakub K
2024-01-22 21:44:59 +01:00
parent 0f122f0201
commit 22728403ee
3 changed files with 22 additions and 3 deletions

View File

@@ -2,12 +2,14 @@ from rest_framework import viewsets, permissions, authentication
from rest_framework.response import Response
from jobposting.models import JobListing, SkillLevels, CompanyLogo, Skill
from core.models import MyUser, AnonymousUserData
from rest_framework import status
from rest_framework import status,
from jobposting.permissions import ClientCredentialPermission
from oauth2_provider.contrib.rest_framework import TokenHasReadWriteScope, OAuth2Authentication
from .auth import OAuth2ClientCredentialAuthentication
from rest_framework.views import APIView
import requests
from django.conf import settings
permissions.IsAuthenticated
from jobposting.serializers import (
JobListingSerializer,
SkillLevelsSerializer,
@@ -86,3 +88,15 @@ class SkillViewset(viewsets.ModelViewSet):
queryset = Skill.objects.all()
serializer_class = SkillSerializer
required_scope = ['main']
class GetAuthTokenView(APIView):
def post(self, request):
client_id = settings.OAUTH_CLIENT_ID
client_secret = settings.OAUTH_CLIENT_SECRET
data = {
'grant_type': 'client_credentials',
'client_id': client_id,
'client_secret': client_secret,
}
response = requests.post('http://izaac.izaac.pl/token', data=data)
return Response(response.json())