Giter VIP home page Giter VIP logo

akarri2001 / notion-and-google-calendar-2-way-sync Goto Github PK

View Code? Open in Web Editor NEW
346.0 16.0 47.0 20.24 MB

2 Way Sync Between Notion Database and Google Calendar

License: GNU General Public License v3.0

Python 99.66% Batchfile 0.13% VBScript 0.21%
notion notion-api notion-database notion-py google-api-python-client google-calendar-api google-calendar notion-automation google-calendar-notion-sync

notion-and-google-calendar-2-way-sync's People

Contributors

akarri2001 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

notion-and-google-calendar-2-way-sync's Issues

TaskNames.append(el['properties'][Task_Notion_Name]['title'][0]['text']['content']) KeyError: 'title'

Hey @akarri2001. This is an amazing project but I'm unable to run it because of so many errors. I followed the docs and changed the token etc. Kindly fix this error. If possible can you make YouTube Tutorial on How to configure this project step by step because from docs I got stuck in between. Thank you

Traceback (most recent call last):
File "E:\Python Work\Notion & Google calender\Notion-and-Google-Calendar-2-Way-Sync\Notion-GCal-2WaySync-Public.py", line 738, in
TaskNames.append(el['properties'][Task_Notion_Name]['title'][0]['text']['content'])
KeyError: 'title'

ValueError and 404Error GoogleAPI

ValueError and 404Error GoogleAPI

HttpError 404 when requesting (https://www.googleapis.com/calendar/v3/calendars)

File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\googleapiclient\http.py", line 935, in execute raise HttpError(resp, content, uri=self.uri) googleapiclient.errors.HttpError: <HttpError 404 when requesting https://www.googleapis.com/calendar/v3/calendars/6cw0v*************group.calendar.google.com/events/7b52796dfobjgijp9vlv8cf80s/move?destination=fd34893uklhjdflgkjsdafdfjklsd%40group.calendar.google.com&alt=json returned "Not Found". Details: "[{'domain': 'global', 'reason': 'notFound', 'message': 'Not Found'}]">

and
During handling of the above exception, another exception occurred:

ValueError("unconverted data remains: %s":

File "C:\Users\User\***\Notion-and-Google-Calendar-2-Way-Sync-main/Notion-GCal-2WaySync-Public.py", line 762, in <module> calEventId = upDateCalEvent(TaskNames[i], makeEventDescription(Initiatives[i], ExtraInfo[i]), datetime.strptime(start_Dates[i], '%Y-%m-%d'), URL_list[i], updatingCalEventIds[i], datetime.strptime(end_Times[i], '%Y-%m-%d'), CurrentCalList[i], CalendarList[i]) File "C:\Users\User\AppData\Local\Programs\Python\Python3.9/_strptime.py", line 568, in _strptime_datetime tt, fraction, gmtoff_fraction = _strptime(data_string, format) File "C:\Users\User\AppData\Local\Programs\Python\Python3.9/_strptime.py", line 352, in _strptime raise ValueError("unconverted data remains: %s" % ValueError: unconverted data remains: [T00:00:00.000+02:00](url)

Access blocked

after pasting the link created with the gcaltoken.py google gives me this message

"Access blocked: NOTION GCAL SYNC has not completed the Google verification process
NOTION GCAL SYNC has not completed the Google verification process. The app is currently being tested, and can only be accessed by developer-approved testers. If you think you should have access, contact the developer.
If you are a developer of NOTION GCAL SYNC, see error details.
Error 403: access_denied"
i cheked every step, and did exactly as the instruccion said

Cannot run the file

I did exactly what the tutorial says but when I run "python3 Notion-GCal-2WaySync-Public.py" it says the following.
What should I do now?

  File "/home/lelouvincx/.local/lib/python3.9/site-packages/notion_client/client.py", line 83, in _parse_response
    response.raise_for_status()
  File "/home/lelouvincx/.local/lib/python3.9/site-packages/httpx/_models.py", line 1105, in raise_for_status
    raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: 404 Client Error: Not Found for url: https://api.notion.com/v1/databases/3b58b006436c477e85c500fb2a41152f/query
For more information check: https://httpstatuses.com/404

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/lelouvincx/Documents/NotionXGCalendar/Notion-GCal-2WaySync-Public.py", line 394, in <module>
    my_page = notion.databases.query(  #this query will return a dictionary that we will parse for information that we want
  File "/home/lelouvincx/.local/lib/python3.9/site-packages/notion_client/api_endpoints.py", line 46, in query
    return self.parent.request(
  File "/home/lelouvincx/.local/lib/python3.9/site-packages/notion_client/client.py", line 133, in request
    return self._parse_response(response)
  File "/home/lelouvincx/.local/lib/python3.9/site-packages/notion_client/client.py", line 93, in _parse_response
    raise APIResponseError(error.response, body)
notion_client.errors.APIResponseError: Could not find database with ID: 3b58b006-436c-477e-85c5-00fb2a41152f.```

Notion client

When I run the code.
It shows the following

ModuleNotFoundError: No module named 'notion_client'

I have installed notion and also no other file named notion.py, so I don't know how to solve that.

The second error is that "GCalTokenLocation is not defined"
I have put my notion token string in the NOTION_TOKEN(line 15)

End Time Notion not appearing in GCal

Hey! Thank you so much for this project! This is exactly what I have been looking for.

I however encouter a problem with the endtimes of events in Notion. If I've read it correctly in the added features you have mentioned that endtimes should be synced both ways. This works when I create an event in GCal; it shows up correctly. But if I enter an endtime in Notion it ends up with the default 60 minutes duration in GCal.

Do I have to adjust something in the code to make this work? I have read the code from top to bottom but can't seem to find the place where this should be adjusted.

Problem bringing GCal events to Notion

Notion feeds GCal perfectly, but when I run Part 4: Bring events (not in Notion already) from GCal to Notion it gives me this error:
File "Notion-GCal-2WaySync-Public.py", line 1253, in
calName = [item['summary'] for item in calItems]
File "Notion-GCal-2WaySync-Public.py", line 1253, in
calName = [item['summary'] for item in calItems]
KeyError: 'summary'
I'm kinda a python newbie, so I'd be grateful for any help ;)

notion_gCal_IDs.append: List index out of range

I just set up your script and can't figure out what's wrong from this error. May you help?

❯ python3 ./Notion-GCal-2WaySync-Public.py 

Nothing new added to GCal
Nothing new updated to GCal
Traceback (most recent call last):
  File "/home/blue/Downloads/Notion-and-Google-Calendar-2-Way-Sync/./Notion-GCal-2WaySync-Public.py", line 841, in <module>
    notion_gCal_IDs.append(result['properties'][GCalEventId_Notion_Name]['rich_text'][0]['text'])
IndexError: list index out of range

File Not Found Error

Hi! For some reason, the credentialsLocation is giving me a FileNotFoundError for my token.pkl. I switched the slashes and even did a quick print on os.path.isfile("token.pkl") and it returned True. Any tips? Thanks!

events organised by others cause crash

Hello,
Thank you for your work!
I noticed that when I accept events' invitations in google calendar, the code exits with an error saying that the email of the event organiser is not "on list" and exiting the execution of the script, without synching any further events. It also refers to line 1259. It seems like a default calendar should be set to sync such events into.
Would be very thankful for your help!

TypeError: string indices must be integers

Notion-GCAl-Sync Iccue

The above error occurs when I run the script while Google Calendar is syncing tasks (not already in my Notion database) to my Notion database. Can't seem to figure out the issue.

googleapi calendar_id has changed

Hi,
I am unable to find my calendar id. It appears as for the "main" calendar, the calendar id is just the email address, ie "[email protected]"
Thus I'm unable to plug the id in the code.
Someone was able to integrate the script with their "main" calendar?

Any help?
Thanks

Problem creating token.pkl file in iOS

Hi,
Thank you very much for your work! Once i get it working, it will make a huge difference in my personal organization. When I hit enter after typing "python3 GCalToken.py" (step 19b, iOS), nothing happens so I can't get the URL necessary to move forward.
Anyone know what I might be doing wrong? I saw a few reddit comments describing a similar issue.

Thanks!

Traceback Error - Index Error: List Index out of Range

Traceback (most recent call last):
File "C:\Users\User\Downloads\Notion-and-Google-Calendar-2-Way-Sync\Notion-GCal-2WaySync-Public.py", line 728, in
CurrentCalList.append(el['properties'][Current_Calendar_Id_Notion_Name]['rich_text'][0]['text']['content'])
IndexError: list index out of range

I always get this error when running the python, but the code works except for syncing my second calendar. Both calendars are mine.

P.S.
I don't think it's a bug but I needed help so posted this here.

Can't update entries trough Notion [Part 2 not working]

THE ISSUE:
In short, my python script won't allow any update in an already existing event through Notion. The "Part 2" of the script doesn't work.

DETAILS OF THE ISSUE:
Whenever I try to update an event on Notion the "result_list" variable (just after the attribution of the variable "my_page") it returns an empty list, so it isn't running both "if" blocks from the part 2:

if len(resultList) > 0:
    for i, el in enumerate(resultList):
        pageId = el['id']
        my_page = notion.pages.update( ##### This checks off that the event has been put on Google Calendar
            **{
                "page_id": pageId, 
                "properties": {
                    Calendar_Notion_Name:  { 
                        'select': {
                            "name": DEFAULT_CALENDAR_NAME
                        },
                    },
                    LastUpdatedTime_Notion_Name: {
                        "date":{
                            'start': notion_time(),
                            'end': None,
                        }
                    }, 
                },
            },
        )

WHAT HAS BEEN OBSERVED:

  • I had "printed" the "result_list" variable and it was observed as an empty list.
  • I suspect that the "result_list" variable its been pulled from the wrong place.
  • When updating the data from an already existing entry (both entries on Google Calendar and Notion) directly from Notion (eg. changing the date from 24/04 to 22/04) the code prioritizes the data of Google Calendar overwriting the data of Notion to the Google Calendar data (eg. returning to day 24/04 on Notion).

Existing tasks will be duplicated if there are more than 100 tasks in Notion's database

Thanks again for the great code.

Now, when I was running this code, it sometimes generated duplicate tasks in the database.
Apparently, there is a problem with the procedure in Part 4 that looks for calendar events that don't exist in Notion.

my_page = notion.databases.query( **{ "database_id": database_id, "filter": { "property": GCalEventId_Notion_Name, "text": { "is_not_empty": True } } }, )

In the Notion API, query responses are limited to 100 at a time.
If there are more than 101 tasks, the IDs contained in the 101st task will not be used for comparison.
Therefore, the program will overlook the IDs that should already be there, so it will add a new column of Notion.

I can't think of a solution right away, so I'll post it in an issue.

HttpError 400, Bad Request when trying to obtain events info

Hi,

My code successfully pushes events from Notion to gcal but not the other way around. The code receives a bad request at line 1247 i.e., x = service.events().list(calendarId = calendarDictionary[el], maxResults = 2000, timeMin = googleQuery() ).execute()

I have checked that the calendar id is correct. Please could anyone help?
Thanks

Error

` File "C:\Users\User\Desktop\Coding_Projects\NotionXGCal\Notion-GCal-2WaySync-Public.py", line 759, in
calEventId = upDateCalEvent(TaskNames[i], makeEventDescription(Initiatives[i], ExtraInfo[i]), datetime.strptime(start_Dates[i], '%Y-%m-%d'), URL_list[i], updatingCalEventIds[i], datetime.strptime(end_Times[i], '%Y-%m-%d'), CurrentCalList[i], CalendarList[i])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\User\Desktop\Coding_Projects\NotionXGCal\Notion-GCal-2WaySync-Public.py", line 374, in upDateCalEvent x= service.events().move(calendarId= currentCalId , eventId= eventId, destination=CalId).execute()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\googleapiclient_helpers.py", line 134, in positional_wrapper
return wrapped(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\googleapiclient\http.py", line 935, in execute
raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 404 when requesting https://www.googleapis.com/calendar/v3/calendars/3cq0v2l8n197dmrie8l7vhjlj0%40group.calendar.google.com/events/7b52796dfobjgijp9vlv8cf80s/move?destination=fd34893uklhjdflgkjsdafdfjklsd%40group.calendar.google.com&alt=json returned "Not Found". Details: "[{'domain': 'global', 'reason': 'notFound', 'message': 'Not Found'}]">

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\User\Desktop\Coding_Projects\NotionXGCal\Notion-GCal-2WaySync-Public.py", line 762, in
calEventId = upDateCalEvent(TaskNames[i], makeEventDescription(Initiatives[i], ExtraInfo[i]), datetime.strptime(start_Dates[i][:-6], "%Y-%m-%dT%H:%M:%S.000"), URL_list[i], updatingCalEventIds[i], datetime.strptime(end_Times[i][:-6], "%Y-%m-%dT%H:%M:%S.000"), CurrentCalList[i], CalendarList[i])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib_strptime.py", line 568, in _strptime_datetime
tt, fraction, gmtoff_fraction = _strptime(data_string, format)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib_strptime.py", line 349, in _strptime
raise ValueError("time data %r does not match format %r" %
ValueError: time data '2023' does not match format '%Y-%m-%dT%H:%M:%S.000'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\User\Desktop\Coding_Projects\NotionXGCal\Notion-GCal-2WaySync-Public.py", line 764, in
calEventId = upDateCalEvent(TaskNames[i], makeEventDescription(Initiatives[i], ExtraInfo[i]), datetime.strptime(start_Dates[i][:-6], "%Y-%m-%dT%H:%M:%S.%f"), URL_list[i], updatingCalEventIds[i], datetime.strptime(end_Times[i][:-6], "%Y-%m-%dT%H:%M:%S.%f"), CurrentCalList[i], CalendarList[i])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib_strptime.py", line 568, in _strptime_datetime
tt, fraction, gmtoff_fraction = _strptime(data_string, format)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib_strptime.py", line 349, in _strptime
raise ValueError("time data %r does not match format %r" %
ValueError: time data '2023' does not match format '%Y-%m-%dT%H:%M:%S.%f'

ValueError("unconverted data remains: %s" and HttpError 404 when requesting https://www.googleapis.com/calendar/v3/calendars

I receive following errors:
1)File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/_strptime.py", line 352, in _strptime
raise ValueError("unconverted data remains: %s" %
ValueError: unconverted data remains: T13:00:00.000-04:00

  1. File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/googleapiclient/http.py", line 935, in execute
    raise HttpError(resp, content, uri=self.uri)
    googleapiclient.errors.HttpError: <HttpError 404 when requesting https://www.googleapis.com/calendar/v3/calendars/3cq0v2l8n197dmrie8l7vhjlj0%40group.calendar.google.com/events/3p10s2o3lst5mhtfkv3v23mvt4/move?destination=njgl69md8r5ckbspstljs3bqug%40group.calendar.google.com&alt=json returned "Not Found". Details: "[{'domain': 'global', 'reason': 'notFound', 'message': 'Not Found'}]">

Can anybody help?

GCalToken.py

File "C:\CalendarSync\GCalToken.py", line 1, in
from googleapiclient.discovery import build
ModuleNotFoundError: No module named 'googleapiclient'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.