0

我正在使用 google nodejs 日历插件来允许医生与患者联系并设置约会。

我正在使用以下代码

const defer = Q.defer();
        oauth2Client.setCredentials({
            refresh_token: options.refreshToken,
        });

        let calendar = google.calendar({
            version: "v3",
            auth: oauth2Client,
        });
        calendar.events.insert(
            {
                auth: oauth2Client,
                singleEvents: true,
                calendarId: "primary",
                resource: {
                    summary: process.env.SITE_NAME + " 1-1 Session",
                    location: options.comments,
                    description: process.env.SITE_NAME + " 1-1 Session with " + options.user.firstName + " " + options.user.lastName + "\n\nInstructions to connect:\n\n" + options.comments,
                    start: {
                        dateTime: new Date(options.startDate),
                        timeZone: "utc",
                    },
                    end: {
                        dateTime: new Date(options.endDate),
                        timeZone: "utc",
                    },
                    attendees: [
                        {
                            email: options.user.email,
                        },
                        {
                            email: options.mentor.email,
                        },
                    ],
                    reminders: {
                        useDefault: false,
                        overrides: [
                            {
                                method: "email",
                                minutes: 15,
                            },
                            {
                                method: "email",
                                minutes: 60,
                            },
                            {
                                method: "popup",
                                minutes: 10,
                            },
                        ],
                    },
                    colorId: 4,
                    sendUpdates: "all",
                    status: "confirmed",
                },
            },
            (err, res) => {
                if (err) {
                    console.dir(err);
                    defer.reject(err);
                } else {
                    defer.resolve(res.data);
                }
            }
        );
        return defer.promise;

如何判断刷新令牌需要重置?如果是这种情况,我需要向医生发送电子邮件。我可以检查“错误”变量吗?如果是这样我应该检查什么?

4

0 回答 0