Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

550
Visualizações
How do I know when a Google calendar event was added there or deleted from there?

I want to sync my own calendar (react-big-calendar) with a Google Calendar. I can retrieve Google calendar events from a primary calendar and display them in my own calendar built using react-big-calendar library. When I add a new event to a Google calendar, I want to see the event added to my own calendar as well without reloading the page. Because on every reload I call a function that fetches the events from a Google Calendar. But I need to do that once there is a change to a Google Calendar. How can I do that?

Backend: python, django

Frontend: react js

        # authorization
        def get_crendetials_google():
            flow = InstalledAppFlow.from_client_secrets_file(
                "credentials.json", SCOPES)
            creds = flow.run_local_server(port=8080)
            pickle.dump(creds, open("token.txt", "wb"))
            return creds

        
        @api_view(['GET'])
        def get_all_events(request):
            creds = None
            if path.exists("token.txt"):
                creds = pickle.load(open("token.txt", "rb"))
            if not creds or not creds.valid:
                if creds and creds.expired and creds.refresh_token:
                    creds.refresh(Request())
                else:
                    creds = get_crendetials_google()
            result = []

            # instantiating a calendar and retrieving google events
            try:
                service = build("calendar", "v3", credentials=creds)
                response = service.events().list(calendarId="primary").execute()
                for event in response["items"]:
                    title = event.get("summary")
                    obj = {}
                    if title:
                        obj["title"] = title
                        obj["start"] = event["start"]
                        obj["end"] = event["end"]
                        result.append(obj)
                result = reformat_events(request, result)
            except OSError as err:
                return Response({'error': "OS error: {0}".format(err)}, status=400)
            return Response(result, status=200)

  useEffect(() => {
      getEvents();
  }, []);

  const getEvents = async () => {
    let response = await fetch("http://localhost:8000/gcevents/", {
      method: "GET",
      headers: {
        "Content-Type": "application/json",
        Authorization: "Bearer " + String(authTokens.access),
      },
    });
    let data = await response.json();

    if (data) {
      props.sendEvents(data);
    }
  };

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda