Django-React google calendar API redirect_uri_mismatch

Мой react находится в http://localhost:3000 мой django находится в http://localhost:8000

Я пытаюсь получить информацию из моего календаря, я нашел этот код в link

Класс Test(APIView):

def get(self, request):
    """Shows basic usage of the Google Calendar API.
    Prints the start and name of the next 10 events on the user's calendar.
    """
    SCOPES = ['https://www.googleapis.com/auth/calendar']

    creds = None
    # The file token.json stores the user's access and refresh tokens, and is
    # created automatically when the authorization flow completes for the first
    # time.
    if os.path.exists("token.json"):
        creds = Credentials.from_authorized_user_file("token.json", SCOPES)
    # If there are no (valid) credentials available, let the user log in.
    if not creds or not creds.valid:
        if creds and creds.expired and creds.refresh_token:
            creds.refresh(Request())
        else:
            flow = InstalledAppFlow.from_client_secrets_file(
                "notes/credentials.json", SCOPES
            )
            creds = flow.run_local_server(port=0)
            # Save the credentials for the next run
            with open("token.json", "w") as token:
                token.write(creds.to_json())

    service = build("calendar", "v3", credentials=creds)

    # Call the Calendar API
    now = datetime.utcnow().isoformat() + "Z"  # 'Z' indicates UTC time
    print("Getting the upcoming 10 events")
    events_result = (
        service.events()
        .list(
            calendarId="primary",
            timeMin=now,
            maxResults=10,
            singleEvents=True,
            orderBy="startTime",
        )
        .execute()
    )
    events = events_result.get("items", [])

    if not events:
        print("No upcoming events found.")
        return JsonResponse({'message': 'No upcoming events found.'}, status=200)

    # Prepare data to be returned
    events_data = []
    for event in events:
        start = event["start"].get("dateTime", event["start"].get("date"))
        events_data.append({"start": start, "summary": event["summary"]})

    return JsonResponse({'events': events_data}, status=200)

`

но когда я пытаюсь отправить запрос с помощью postman, у меня возникает ошибка

enter image description here

idk how to solve it. I have been reading and they tell me to add URLs to the Authorized JavaScript origins and the Authorized redirect URIs of the credential setting in the api, but nothing works. Моя конечная цель - создание событий в календаре, но я пытаюсь получить их на данный момент, и это не работает.

Вернуться на верх