The canonical examples for using CalDAV always use username/password authentication. However Nextcloud supports OAuth2, therefore I would like to use CalDAV via oauth.
I already have done the same with the Google calendar API, but just adapting the oauth2client sample provided by Google:
client_secrets = 'client_secrets.json'
flow = client.flow_from_clientsecrets(client_secrets, scope="",
message=tools.message_if_missing(client_secrets))
storage = file.Storage('calendar_credentials.dat')
credentials = storage.get()
if credentials is None or credentials.invalid:
credentials = tools.run_flow(flow, storage)
http = credentials.authorize(http=build_http())
by replacing build_http() by an instance of caldav.DAVClient does not work. The internal request() APIs are quite different and calling any method of the caldav client will miserably fail when wrapped by authorize(). So, the question is: how to integrate caldav.DAVClient with oauth2client?
Also documentation on using OAuth with nextCloud is scarce. I have found this posting, but it is still not obvious what goes where.