Google calendar api 谷歌日历:错误:超出未经验证使用的每日限制

Google calendar api 谷歌日历:错误:超出未经验证使用的每日限制,google-calendar-api,google-oauth,Google Calendar Api,Google Oauth,我试图按照google文档()中提供的google calendar api nodejs示例来访问我的主要google日历事件,我收到了以下错误:“超出了未经验证使用的每日限制。继续使用需要注册。” 我知道我正确地通过了OAuth流,因为我的具有日历访问权限的项目列在这里: 以下是我的范围: const SCOPESAUTH = [ 'https://www.googleapis.com/auth/calendar', 'https://www.googleapis.com/auth/cale

我试图按照google文档()中提供的google calendar api nodejs示例来访问我的主要google日历事件,我收到了以下错误:“超出了未经验证使用的每日限制。继续使用需要注册。”

我知道我正确地通过了OAuth流,因为我的具有日历访问权限的项目列在这里:

以下是我的范围:

const SCOPESAUTH = [
'https://www.googleapis.com/auth/calendar',
'https://www.googleapis.com/auth/calendar.readonly',
'https://www.googleapis.com/auth/calendar.events'
])

在OAuth同意屏幕选项卡的开发人员控制台中,我没有设置“Google API的作用域”部分中的作用域。当我尝试设置它们时,它说Google必须批准对这些敏感作用域的访问。但是,许可屏幕上没有显示“未经验证的应用程序”。该应用程序正在开发中,而不是在生产中

谷歌的文档说:“一个DailyLimitExcelled错误表明你的项目已经达到了礼节性API限制。”在开发者控制台的配额页面上,我的使用记录为0。我已经启用了谷歌日历API

以下是OAuth云函数:

    const functionsOauthClient = new OAuth2Client(CONFIG_CLIENT_ID, CONFIG_CLIENT_SECRET,
    FUNCTIONS_REDIRECT);

// visit the URL for this Function to request tokens
exports.authgoogleapi = functions.https.onRequest((req, res) => {
    // req.query.id === device id of the user
    res.set('Cache-Control', 'private, max-age=0, s-maxage=0');
    res.redirect(functionsOauthClient.generateAuthUrl({
        access_type: 'offline',
        scope: SCOPESAUTH,
        prompt: 'consent',
        state: req.query.id
    }));
});


// redirect URI
exports.oauthcallback = functions.https.onRequest(async (req, res) => {
    res.set('Cache-Control', 'private, max-age=0, s-maxage=0');
    const code = req.query.code;
    try {
        const {tokens} = await functionsOauthClient.getToken(code);
        // store the tokens for retrieval by client app that is then sent to the getEvents cloud cloud unction
        admin.database().ref(`Devices/${req.query.state}/api_tokens`).set(tokens);
        return res.status(200).send('App successfully configured with new Credentials.');
    } catch (error) {
        return res.status(400).send(error);
    }
});
对oauthcallback的调用返回状态200

下面是抛出错误的代码。注意,req.body.token是在OAuth流期间生成的,保存到Firebase,然后作为参数传递给这个google云函数

    exports.getEvents = functions.https.onRequest((req, res) => {
      ...

      const authClient = new OAuth2Client(CONFIG_CLIENT_ID, CONFIG_CLIENT_SECRET, FUNCTIONS_REDIRECT);
      authClient.setCredentials(req.body.token);
      const calendar = google.calendar({version: 'v3', authClient});
      return calendar.events.list({
          calendarId: 'primary',
          timeMin: (new Date()).toISOString(),
          maxResults: 10,
          singleEvents: true,
          orderBy: 'startTime',
      }, (err, result) => {...
有什么建议吗?谢谢。

我发现了问题

const calendar = google.calendar({version: 'v3', authClient})
应该是:

const calendar = google.calendar({version: 'v3', auth: authClient})

authClient似乎没有经过身份验证,我看不出您在哪里使用
getAccessToken
函数来设置令牌。请提供您用于身份验证流的完整代码。我已编辑了该问题以显示OAuth流。如果您在
setCrendentials
中使用它之前登录
req.body.token
,它应该会给您一个有效的刷新令牌,您可以使用它来测试日历列表请求,它在那里对您有效吗?另外,您是否手动同意访问?按照快速启动,您需要在用户登录后访问重定向URI,并通过复制和粘贴给定的
code
变量首次授予对应用程序的访问权。