小编Ore*_*ren的帖子

类型错误:无法读取未定义的属性“redirect_uris”

我想编写一个应用程序来处理我的一些以某种方式标记的 Gmail 电子邮件。

这里的示例代码为我的代码提供了一个起点(我使用 Promise 而不是 async wait 重写了代码):

'use strict';

const path = require('path');
const { google } = require('googleapis');
const { authenticate } = require('@google-cloud/local-auth');

authenticate({
    keyfilePath: path.join(__dirname, 'key.json'),
    scopes: [
        'https://www.googleapis.com/auth/gmail.readonly',
    ],
}).then(auth => {
    google.options({ auth })

    gmail.users.messages.list({
        userId: "me",
    }).then((res) => {
        console.log(res.data)
    }).catch(err => {
        console.log(err)
    })
}).catch(err => {
    console.log(err);
})
Run Code Online (Sandbox Code Playgroud)

以下是我到目前为止所采取的步骤:

  • 创建了一个谷歌云项目
  • 创建具有所有者角色的服务帐户
  • 从服务帐户下载密钥文件并将其复制到我的代码目录中,如下所示key.json
  • 运行代码:
GOOGLE_APPLICATION_CREDENTIALS="$(pwd)/key.json" node index.js
Run Code Online (Sandbox Code Playgroud)

这是我收到的错误:

TypeError: Cannot read property 'redirect_uris' of undefined
    at authenticate (/home/user/dev/gmail-processor/node_modules/@google-cloud/local-auth/build/src/index.js:46:15)
    at …
Run Code Online (Sandbox Code Playgroud)

javascript node.js google-cloud-platform gmail-api google-auth-library-nodejs

8
推荐指数
2
解决办法
5113
查看次数

如何清理我的lua状态堆栈?

我使用lua C-API读取存储在lua文件中的配置数据.

我在文件中有一个漂亮的小表,我编写了一个查询C函数来解析表中的特定字段.(它的确有效!)

它通过一遍又一遍地调用这些函数中的一些来工作:

... 
lua_getglobal (...); 
lua_pushinteger (...); 
lua_gettable (...); 
lua_pushstring (...); 
lua_gettable (...); 
lua_lua_getfield (...);
...
Run Code Online (Sandbox Code Playgroud)

你明白了.

在我查询完这样的数据之后,我是否必须清理堆栈?

c c++ lua

5
推荐指数
1
解决办法
1353
查看次数