Skip to content

Cannot client.fetchCalendars(); #240

@barrct

Description

@barrct

We are working on trying to display calendar data to users and as this is my first time working with tsdav I'm sure that I'm missing something. Unfortunately, the error "Error: no account for fetchCalendars" doesn't really mean much and I can't see any error code lookups.

I have tried to add in "username: '@gmail.com'," to the DAVClient() call to see if it wanted the account name with the other credentials, but I have the same error.

Since I am not using a username/password, I am not getting any refresh token, but I was expecting that the access token would work for 60 mins based on the auth. I was going to worry about refreshing and cleaning after I had any data flowing in the first place.

What am I doing wrong?

    const client = new tsdav.DAVClient({
        serverUrl: 'https://apidata.googleusercontent.com/caldav/v2/',
        credentials: {
            tokenUrl: 'https://accounts.google.com/o/oauth2/token',
            refreshToken: <access token from oAuth initImplicitFlow>,
            clientId: <company clientid>,
            clientSecret: <company secret>,
        },
        authMethod: 'Oauth',
        defaultAccountType: 'caldav',
    });

    console.log('fetchCalendars');
    try {
        const calendars = await client.fetchCalendars();
        console.log(calendars);
    } catch (e) {
        console.log(e);
    }

Error message

2025-01-03T02:40:50.289Z	0e3fe1ba-61c0-4b9e-88a0-e601217e3e08	INFO	fetchCalendars
2025-01-03T02:40:50.290Z	0e3fe1ba-61c0-4b9e-88a0-e601217e3e08	INFO	Error: no account for fetchCalendars
    at fetchCalendars (/var/task/node_modules/tsdav/dist/tsdav.cjs.js:860:19)
    at /var/task/node_modules/tsdav/dist/tsdav.cjs.js:1375:12
    at DAVClient.fetchCalendars (/var/task/node_modules/tsdav/dist/tsdav.cjs.js:1751:131)
    at exports.handler (/var/task/index.js:93:40)
    at Runtime.handleOnceNonStreaming (file:///var/runtime/index.mjs:1173:29)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions