google-api-nodejs-client

How to impersonate an admin user when using getClient() in the Google API NodeJS client

南笙酒味 提交于 2021-02-16 18:07:28
问题 Per the recommendation in the defaultauth sample, I am trying to access the directory api for a domain which I have created a service account for. Here is the code I am attempting to connect with: import { google } from 'googleapis' const authClient = await google.auth.getClient({ scopes: ['https://www.googleapis.com/auth/admin.directory.user.readonly'] }) const service = google.admin('directory_v1') console.log( await service.users.list({ auth: authClient, domain: <redacted> }) ) However,

How to impersonate an admin user when using getClient() in the Google API NodeJS client

主宰稳场 提交于 2021-02-16 18:06:37
问题 Per the recommendation in the defaultauth sample, I am trying to access the directory api for a domain which I have created a service account for. Here is the code I am attempting to connect with: import { google } from 'googleapis' const authClient = await google.auth.getClient({ scopes: ['https://www.googleapis.com/auth/admin.directory.user.readonly'] }) const service = google.admin('directory_v1') console.log( await service.users.list({ auth: authClient, domain: <redacted> }) ) However,

How to impersonate an admin user when using getClient() in the Google API NodeJS client

 ̄綄美尐妖づ 提交于 2021-02-16 18:06:15
问题 Per the recommendation in the defaultauth sample, I am trying to access the directory api for a domain which I have created a service account for. Here is the code I am attempting to connect with: import { google } from 'googleapis' const authClient = await google.auth.getClient({ scopes: ['https://www.googleapis.com/auth/admin.directory.user.readonly'] }) const service = google.admin('directory_v1') console.log( await service.users.list({ auth: authClient, domain: <redacted> }) ) However,

Is there a way to directly read the content of a JSON file in a bucket Google Cloud Datastore via node.js without having to download it before?

柔情痞子 提交于 2021-01-29 14:23:44
问题 I am a Python developer, but the circumstances of a project I am working on now, oblige me to find a solution in Node.js. I have check the documentation In the class File, I have this method: createReadStream, but who force me to download in local before read it. However, the solution I search is just like to save the content in a variable so that I can read and interpret as I want. This is the script of createReadStream() method: var storage = require('@google-cloud/storage')(); var bucket =

How to use Service Account to access GMAIL API for a GSuite email account

╄→гoц情女王★ 提交于 2021-01-29 10:07:59
问题 I want my service account to impersonate one of the users in the GSuite. I have created a project via GCP enabled GMail API in the project added a service account to that project enabled the domain-wide delegation in the service account settings on the GCP added an API Client with service account id in advanced settings via Google Admin panel for the GSuite While going through docs (java), I saw this GoogleCredential credential = GoogleCredential.fromStream(new FileInputStream("MyProject-1234

Google Spreadsheet API setDataValidation with Regex

[亡魂溺海] 提交于 2021-01-29 09:59:51
问题 Im trying to generate an Google Spreadsheet Template with some Validation with their API, using the Node.Js Package from Google. This is my current Request: { "setDataValidation": { "range": { "sheetId": 1656514345, "startRowIndex": 0, "endRowIndex": 0, "startColumnIndex": 1, "endColumnIndex": 1000 }, "rule": { "condition": { "type": "CUSTOM_FORMULA", "values": [ { "userEnteredValue": "=REGEXMATCH(TO_TEXT(A2:A1000); '([1-9]){4}[-]([1-9]){2}[-]([1-9]){2}$')" } ] }, "inputMessage": "TEST

nodejs gmail failedPrecondition

…衆ロ難τιáo~ 提交于 2021-01-28 13:31:31
问题 so i am using this: https://github.com/google/google-api-nodejs-client#using-api-keys here is the nodejs code: router.get("/deals", function(req, res, next) { var key = require('../gmail-a574e06ad196.json'); var jwtClient = new google.auth.JWT( key.client_email, null, key.private_key, ['https://www.googleapis.com/auth/gmail.readonly', 'https://mail.google.com/'], // an array of auth scopes null ); jwtClient.authorize(function (err, tokens) { if (err) { res.send('123'); return; } console.log(

express-fileupload to Google Drive API

混江龙づ霸主 提交于 2021-01-27 19:43:00
问题 I can successfully save my uploaded image in my public uploads folder and integrate google drive api but it seems that it is uploading an empty file. What should I put in the body parameter of the Google Drive API from my req.files data {name: 'country.jpg',data: <Buffer ff d8 ff e0 00 10 4a 46 49 46 00 01 01 01 00 48 00 48 00 00 ff ed 26 0c 50 68 6f 74 6f 73 68 6f 70 20 33 2e 30 00 38 42 49 4d 04 04 00 00 00 00 00 22 ... 246290 more bytes>,size: 246340,encoding: '7bit',tempFilePath: ''

Unable to send mail using gmail api node js

风格不统一 提交于 2020-12-13 02:59:29
问题 I have followed gmail api for sending email. I am getting error as: "message": "400 - \"{\n \\"error\\": {\n \\"errors\\": [\n {\n \\"domain\\": \\"global\\",\n \\"reason\\": \\"invalidArgument\\",\n \\"message\\": \\"'raw' RFC822 payload message string or uploading message via /upload/* URL required\\"\n }\n ],\n \\"code\\": 400,\n \\"message\\": \\"'raw' RFC822 payload message string or uploading message via /upload/* URL required\\"\n }\n}\n\"" Here is the piece of code I have written for

Unable to send mail using gmail api node js

独自空忆成欢 提交于 2020-12-13 02:59:14
问题 I have followed gmail api for sending email. I am getting error as: "message": "400 - \"{\n \\"error\\": {\n \\"errors\\": [\n {\n \\"domain\\": \\"global\\",\n \\"reason\\": \\"invalidArgument\\",\n \\"message\\": \\"'raw' RFC822 payload message string or uploading message via /upload/* URL required\\"\n }\n ],\n \\"code\\": 400,\n \\"message\\": \\"'raw' RFC822 payload message string or uploading message via /upload/* URL required\\"\n }\n}\n\"" Here is the piece of code I have written for