i want to make google oauth and when google redirect me with get req state and code then when i want to post it my djoser url in django rest i got non-field-errors :
session value state is missing 400 bad request to API_URL = 'https://7bfb-31-56-195-93.ngrok-free.app/auth/o/google-oauth2/'
class RedirectSocial(APIView):
def get(self, request, *args, **kwargs):
code = request.GET.get('code', '')
state = request.GET.get('state', '')
json_obj = {'code': code, 'state': state}
print(json_obj)
header = {
'Content-Type': 'application/x-www-form-urlencoded',
}
query_params = urllib.parse.urlencode(json_obj)
print(query_params)
form_data = {
'code': code,
'state': state,
'client_id': '855150297727-frj54btbp93i1g50tglt5klg7g1jvug6.apps.googleusercontent.com',
'client_secret': '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',
'redirect_uri': 'https://7bfb-31-56-195-93.ngrok-free.app/google',
'grant_type': 'authorization_code',
}`
# Make the POST request using the requests library
` api_url = f"{API_URL}?{query_params}" # Replace this with your actual API URL
response = requests.post(API_URL, data=form_data )
# Assuming the response contains the data you need
response_data = response.json()
print(response_data)
# Return the JSON object as the response to the GET request
return Response(json_obj)
i want to get access token from that end point