List Calendars in Nextcloud Calendar

List all calendars a user has access to in Nextcloud calendar.

Script nextcloud Verified

by marcel klehr12 ยท 7/23/2024

The script

Submitted by nextcloud Python3
Verified 77 days ago
1
import caldav
2
import base64
3

4
# You can import any PyPi package.
5
# See here for more info: https://www.windmill.dev/docs/advanced/dependencies_in_python
6

7
# you can use typed resources by doing a type alias to dict
8
nextcloud = dict
9

10

11
def main(Nextcloud: nextcloud):
12
    headers = {}
13

14
    with caldav.DAVClient(
15
        url=Nextcloud['baseUrl'] + '/remote.php/dav/calendars/'+ Nextcloud['userId'] +'/',
16
        username=Nextcloud['userId'],
17
        password=Nextcloud['token'],
18
        headers=headers,
19
    ) as client:
20
        my_principal = client.principal()
21
        return my_principal.calendars()
22

23

Other submissions
  • Submitted by marcel klehr12 Python3
    Created 568 days ago
    1
    import caldav
    2
    import base64
    3
    
    
    4
    # You can import any PyPi package.
    5
    # See here for more info: https://www.windmill.dev/docs/advanced/dependencies_in_python
    6
    
    
    7
    # you can use typed resources by doing a type alias to dict
    8
    nextcloud = dict
    9
    
    
    10
    
    
    11
    def main(NextcloudResource: nextcloud, userId: str, useAppApiAuth: bool = False):
    12
        if useAppApiAuth:
    13
            headers = {
    14
                "AA-VERSION": "2.3.0",
    15
                "EX-APP-ID": "flow",
    16
                "EX-APP-VERSION": "1.0.0",
    17
                "AUTHORIZATION-APP-API": base64.b64encode(
    18
                  f"{userId}:{NextcloudResource['password']}".encode('utf-8')).decode('utf-8'),
    19
              }
    20
        else:
    21
            headers = {}
    22
    
    
    23
        with caldav.DAVClient(
    24
            url=NextcloudResource['baseUrl'] + '/remote.php/dav/calendars/'+userId+'/',
    25
            username=userId,
    26
            password=NextcloudResource['password'],
    27
            headers=headers,
    28
        ) as client:
    29
            my_principal = client.principal()
    30
            return my_principal.calendars()
    31