标签: google-api-nodejs-client

未找到函数:group_concat

我对使用“group_concat”BigQuery 函数执行查询很感兴趣。当我直接在 BigQuery 界面中执行查询时,查询成功结束,但是当我尝试通过 Node js 执行该查询时,出现了以下错误:

errors:
   [ { domain: 'global',
       reason: 'invalidQuery',
       message: 'Function not found: group_concat at [4:3]',
       locationType: 'other',
       location: 'query' } ]
Run Code Online (Sandbox Code Playgroud)

代码不是问题,因为它执行一个简单的查询没有任何问题。

我的查询:

SELECT
  st_hub_session_id,
  num_requests,
  group_concat( group.code, '|' ) as Codes
FROM
  table.name
GROUP BY
  st_hub_session_id,
  group_concat
LIMIT
  1000
Run Code Online (Sandbox Code Playgroud)

问题可能出在哪里?

google-bigquery google-api-nodejs-client

4
推荐指数
1
解决办法
4661
查看次数

Google Drive API推送通知无法停止/取消

我正在观看Drive资源.设置手表(使用带有node.js和drive.file.watch的googleapis 0.2.13-alpha客户端):

exports.subscribeDriveCallbacksCmd = function( user, fileId ){
  var userId = user.id;
  var baseUrl = exports.BASE_URL;
  var subscribeUrl = baseUrl+"/incoming/file";
  var watchId = 'id-'+fileId+'-'+(new Date()).getTime();
  var subscription = {
    id: watchId,
    token: userId+':'+fileId,
    type: 'web_hook',
    address: subscribeUrl,
    params:{
      ttl: 600
    }
  };
  var params = {
    fileId: fileId
  };

//var cmd = client.drive.files.watch( params, subscription );

// FIXME - Hack around bug in RPC implememntation var hack = {channel:subscription}; for( var key in params ){ hack[key] = params[key]; } var …

google-drive-api google-api-nodejs-client

3
推荐指数
1
解决办法
1664
查看次数

如何使用refreshAccessToken方法在google-api-nodejs-client中生成新的accessstoken

我看到这个pull请求添加了一个使用保存的刷新令牌刷新访问令牌的方法.我不清楚如何使用它.我已从原始getToken请求中保存了令牌(包括刷新令牌),现在我正在新会话中从数据库中检索令牌.如何在OAuth2Client上设置凭据,以便我可以调用refreshAccessToken并获取新的accessstoken?

google-api node.js google-api-nodejs-client

3
推荐指数
1
解决办法
5275
查看次数

node.js(Javascript) google-api-nodejs-client - 列表消息

我的问题被否决了,所以我正在重写它,希望这更简洁

我一直在编写一个 JavaScript 函数来列出收件箱中的邮件。

使用 - 官方“google-api-nodejs-client”、node.js、电子(和 javascript) 目标:在 gmail 收件箱中列出消息 为此,我需要先授权,然后请求消息

授权 -我从谷歌node.js快速入门复制了代码 - 这在电子中有效(实际上是node.js,因为它是一个命令行脚本)。

询问消息 -谷歌有一个例子,我复制了它,调整了一些部分,但不起作用。我认为我正在使用的示例不是为node.js“google-api-nodejs-client”设计的。- 也许需要不同的授权

这是谷歌示例中的 listmessages 函数,我似乎无法弄清楚如何使用列表标签的授权来使其工作。这就是我尝试过的

  • 将gapi更改为google
  • 将 userId 更改为“我”
  • 改变给它一个查询

不使用客户端库。

Does not use a client library.

/**
 * Retrieve Messages in user's mailbox matching query.
 *
 * @param  {String} userId User's email address. The special value 'me'
 * can be used to indicate the authenticated user.
 * @param  {String} query String used to filter the Messages listed.
 * @param …
Run Code Online (Sandbox Code Playgroud)

google-api google-api-nodejs-client gmail-api

3
推荐指数
1
解决办法
1971
查看次数

Google OAuth2 API 刷新令牌

我正在使用该google-auth-library-nodejs库集成到许多 GMail 帐户中,以获取电子邮件列表。

我的处理流程很简单:

1)尝试使用此功能对客户端进行授权:

function _authorise(mailBox, callback) {
  let auth = new googleAuth();

  let clientId = eval(`process.env.GMAIL_API_CLIENT_ID_${mailBox.toUpperCase()}`);
  let clientSecret = eval(`process.env.GMAIL_API_CLIENT_SECRET_${mailBox.toUpperCase()}`);
  let redirectUri = eval(`process.env.GMAIL_API_REDIRECT_URI_${mailBox.toUpperCase()}`);
  let tokenFile = process.env.GMAIL_API_TOKEN_PATH + mailBox.toLowerCase()+ process.env.GMAIL_API_TOKEN_BASE_FILE_NAME;

  let oauth2Client = new auth.OAuth2(clientId, clientSecret, redirectUri);
  fs.readFile(tokenFile, ((err, token) => {
    if (err) {
      _getNewToken(mailBox,oauth2Client,callback);
    } else {
      oauth2Client.credentials = JSON.parse(token);
      callback(oauth2Client);
    }
  }))
}
Run Code Online (Sandbox Code Playgroud)

2) 该方法将检查文件中是否存在令牌。如果未找到该文件,以下函数将创建该文件:

function _getNewToken(mailBox, oauth2Client, callback) {
  var authUrl = oauth2Client.generateAuthUrl({
    access_type: 'offline',
    scope: process.env.GMAIL_API_SCOPES
  });
  console.log('To authorize this …
Run Code Online (Sandbox Code Playgroud)

google-api node.js oauth-2.0 google-api-nodejs-client

3
推荐指数
2
解决办法
1万
查看次数

Google People API注释

在Google的People API中,是否可以访问/更改联系人的注释? 人定义

创建联系人https://contacts.google.com/时,可以设置字段“便笺”,这就是我想要的。

到目前为止,我为此使用了官方的NodeJS API和“ UserDefined”。

提前致谢,

google-api-nodejs-client google-people

3
推荐指数
1
解决办法
467
查看次数

Google Sheet Api获取函数返回nodejs中的未定义值

function changeData(auth,sheetId) {
  var sheets = google.sheets('v4');
  sheets.spreadsheets.values.update({
    auth: auth,
    spreadsheetId: sheetId,
    range: 'Sheet1!D6', 
    valueInputOption: "USER_ENTERED",
    resource: {
      values: [ ["abc"] ]
    }
  }, (err, response) => {
    if (err) {
      console.log('The API returned an error: ' + err);
      return;
    } else {
        console.log("Appended");
    }
  });
}
Run Code Online (Sandbox Code Playgroud)

我可以让上面的函数工作,它可以很好地改变值,但是下面的函数不会返回值并且表示检索到0行.我究竟做错了什么?

function read(auth,sheet_id)
    {
      var sheets = google.sheets('v4');
        sheets.spreadsheets.values.get({
        auth: auth,
        spreadsheetId: sheet_id,
        range: 'Sheet1!D6'
      }, function(err, result) {
        if(err) {
          // Handle error
          console.log(err);
        } else {
          var numRows = result.values ? …
Run Code Online (Sandbox Code Playgroud)

google-api google-api-nodejs-client

3
推荐指数
1
解决办法
418
查看次数

如何在 Node.js 中使用 Google 跟踪代码管理器

dataLayer我正在将一个简单的电子商务对象推送到客户端的Google 跟踪代码管理器。它工作正常,但我需要将其移至服务器。

我找到了Google API Node.js 客户端库,但它还很年轻,我找不到任何有效的示例。

有人设法做到这一点吗?如何使用 node.js 中的 google-api-nodejs-client 完成以下任务?

dataLayer.push({
  event: 'purchase',
  user: 'user_1234',
  transactionId: 'trans_123',
  transactionAffiliation: 'Acme Clothing',
  transactionTotal: 11.99,
  transactionProducts: [
    {
      id: '1234',
      sku: 'SKU47',
      name: 'Fluffy Pink Bunnies',
      price: 11.99,
      quantity: 1
    }
  ]
});
Run Code Online (Sandbox Code Playgroud)

google-analytics node.js google-api-nodejs-client google-apis-explorer

3
推荐指数
1
解决办法
7484
查看次数

通过 nodejs 使用不记名令牌进行谷歌云身份验证

我的客户有一个在 Google Cloud Run 上运行的 GraphQL API。

我收到了一个用于身份验证的服务帐户以及对 gcloud 命令行工具的访问权限。

像这样使用 gcloud 命令行时:

gcloud auth print-identity-token
Run Code Online (Sandbox Code Playgroud)

我可以生成一个令牌,该令牌可用于向 api 发出发布请求。这有效,我可以从邮递员、失眠症和我的 nodejs 应用程序成功地向 api 发出请求。

但是,当我将 JWT 身份验证与“googleapis”或“google-auth”npm 库一起使用时,如下所示:

var { google } = require('googleapis')

let privatekey = require('./auth/google/service-account.json')

let jwtClient = new google.auth.JWT(
  privatekey.client_email,
  null,
  privatekey.private_key,
  ['https://www.googleapis.com/auth/cloud-platform']
)

jwtClient.authorize(function(err, _token) {
  if (err) {
    console.log(err)
    return err
  } else {
    console.log('token obj:', _token)
  }
})
Run Code Online (Sandbox Code Playgroud)

这将输出一个“承载”令牌:

token obj: {
  access_token: 'ya29.c.Ko8BvQcMD5zU-0raojM_u2FZooWMyhB9Ni0Yv2_dsGdjuIDeL1tftPg0O17uFrdtkCuJrupBBBK2IGfUW0HGtgkYk-DZiS1aKyeY9wpXTwvbinGe9sud0k1POA2vEKiGONRqFBSh9-xms3JhZVdCmpBi5EO5aGjkkJeFI_EBry0E12m2DTm0T_7izJTuGQ9hmyw',
  token_type: 'Bearer',
  expiry_date: 1581954138000,
  id_token: undefined,
  refresh_token: 'jwt-placeholder'
}
Run Code Online (Sandbox Code Playgroud)

然而,这个不记名令牌不能像上面那样工作,并且在发出与 …

google-api-nodejs-client google-cloud-platform gcloud google-cloud-run

3
推荐指数
1
解决办法
2896
查看次数

如何使用服务帐户访问 GSuite 电子邮件帐户的 GMAIL API

我希望我的服务帐户能够模拟 GSuite 中的用户之一。我有

  • 通过 GCP 创建项目
  • 在项目中启用GMail API
  • 向该项目添加了一个服务帐户
  • domain-wide delegation在服务帐户设置中启用GCP
  • 通过 Google 管理控制台在高级设置中API Client添加了service account idGSuite

在浏览文档(java)时,我看到了这个

GoogleCredential credential = GoogleCredential.fromStream(new FileInputStream("MyProject-1234.json"))
    .createScoped(Collections.singleton(SQLAdminScopes.SQLSERVICE_ADMIN))
    .createDelegated("user@example.com");
Run Code Online (Sandbox Code Playgroud)

在这里,他们指定服务帐户应模拟哪个用户。这段代码是java中的。我需要在nodejs 中完成同样的事情。

在查看nodejs-clientfor的文档时googleapis,我发现了这一点:

const {google} = require('googleapis');

const auth = new google.auth.GoogleAuth({
  keyFile: '/path/to/your-secret-key.json',
  scopes: ['https://www.googleapis.com/auth/cloud-platform'],
});
Run Code Online (Sandbox Code Playgroud)

const {google} = require('googleapis');

const oauth2Client = new google.auth.OAuth2(
  YOUR_CLIENT_ID,
  YOUR_CLIENT_SECRET,
  YOUR_REDIRECT_URL
);

// set auth as a global default
google.options({
  auth: oauth2Client
});
Run Code Online (Sandbox Code Playgroud)

GoogleAuth和这里有什么区别OAuth2 …

node.js google-api-client google-api-nodejs-client gmail-api

3
推荐指数
1
解决办法
3883
查看次数