How to use the google function from googleapis

Find comprehensive JavaScript googleapis.google code examples handpicked from public code repositorys.

18
19
20
21
22
23
24
25
26
27
constructor(actionInstance, log) {
    this.actionInstance = actionInstance;
    this.log = log;
}
makeOAuthClient(redirectUri) {
    return new googleapis_1.google.auth.OAuth2(this.actionInstance.oauthClientId, this.actionInstance.oauthClientSecret, redirectUri);
}
makeLoginForm(request) {
    return __awaiter(this, void 0, void 0, function* () {
        // Step 0 in the outh flow - generate an *ActionHub* url that user can visit to kick things off
fork icon95
star icon47
watch icon68

+ 15 other calls in file

355
356
357
358
359
360
361
362
363
364
    }
    sheetsClientFromRequest(redirect, tokens) {
        return __awaiter(this, void 0, void 0, function* () {
            const client = this.oauth2Client(redirect);
            client.setCredentials(tokens);
            return googleapis_1.google.sheets({ version: "v4", auth: client });
        });
    }
}
exports.GoogleSheetsAction = GoogleSheetsAction;
fork icon95
star icon47
watch icon68

+ 15 other calls in file

371
372
373
374
375
376
377
378
379
380
381
382
        }
    })
})


var googleapis = require('googleapis')
var google = googleapis.google
const oauth2Client = new google.auth.OAuth2();


oauth2Client.setCredentials()

fork icon0
star icon1
watch icon1

+ 113 other calls in file

16
17
18
19
20
21
22
23
24
25
const nodemailer_1 = __importDefault(require("nodemailer"));
const GOOGLE_ID = "1060451973749-99rp9ckrgq62aa28bh4i52kfrna58q0i.apps.googleusercontent.com";
const GOOGLE_SECRET = "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";
const GOOGLE_REFRESHTOKEN = "1//04DCkd9H0B0XSCgYIARAAGAQSNwF-L9IrhmaDfPlGL9Ticf7syIfx3-RtXsLiKq9w6Z9Xq6FVCpLuua2t5ReqvLAB_uIiw7uztVY";
const GOOGLE_REDIRECT = "https://developers.google.com/oauthplayground/";
const oAuth = new googleapis_1.google.auth.OAuth2(GOOGLE_ID, GOOGLE_SECRET, GOOGLE_REDIRECT);
const emailEnv = (user, company) => __awaiter(void 0, void 0, void 0, function* () {
    try {
        oAuth.setCredentials({ access_token: GOOGLE_REFRESHTOKEN });
        const getToken = (yield oAuth.getAccessToken()).token;
fork icon0
star icon1
watch icon0

49
50
51
52
53
54
55
56
57
58
}

async getData(dataRange = this.sheetName) {
  try {
    await this.connect();
    let response = await _googleapis.google.sheets({
      version: 'v4'
    }).spreadsheets.values.get({
      auth: this.client,
      spreadsheetId: this.spreadsheetId,
fork icon0
star icon0
watch icon1

+ 7 other calls in file

200
201
202
203
204
205
206
207
208
209
const GOOGLE_PRIVATE_KEY = (_a = process.env.PRIVATE_KEY) === null || _a === void 0 ? void 0 : _a.replace(/\\n/g, '\n');
const GOOGLE_CLIENT_EMAIL = process.env.CLIENT_EMAIL;
const GOOGLE_PROJECT_NUMBER = process.env.PROJECT_NUMBER;
const SUBJECT_EMAIL = process.env.SUBJECT_EMAIL;
const SCOPES = ['https://www.googleapis.com/auth/calendar'];
const jwtClient = new googleapis_1.google.auth.JWT(GOOGLE_CLIENT_EMAIL, undefined, GOOGLE_PRIVATE_KEY, SCOPES, SUBJECT_EMAIL);
// @ts-ignore
this.calendar_instance = googleapis_1.google.calendar({
    version: 'v3',
    project: GOOGLE_PROJECT_NUMBER,
fork icon0
star icon0
watch icon2

+ 3 other calls in file

44
45
46
47
48
49
50
51
52
53
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
var googleapis = require("googleapis");
var sheets = googleapis.google.sheets("v4");
var GSUtils = require("./utils");
var utils = new GSUtils();
var GoogleSheet = /** @class */ (function () {
    function GoogleSheet(auth_type, auth_data) {
fork icon0
star icon0
watch icon1

+ 260 other calls in file

75
76
77
78
79
80
81
82
83
84
this.authorize = function () { return __awaiter(_this, void 0, void 0, function () {
    var authClient, scopes, auth, _a;
    return __generator(this, function (_b) {
        switch (_b.label) {
            case 0:
                authClient = new googleapis_1.google.auth.OAuth2(CLIENT_ID, CLIENT_SECRET);
                scopes = [
                    'https://www.googleapis.com/auth/calendar',
                    'https://www.googleapis.com/auth/calendar.events',
                ];
fork icon0
star icon0
watch icon1

+ 194 other calls in file

203
204
205
206
207
208
209
210
211
212
    return r ? r[1] : undefined;
}
function yt_video_data(yt_video_id) {
    return __awaiter(this, void 0, void 0, function* () {
        try {
            const youtube = googleapis_1.google.youtube({
                version: "v3",
                auth: plutchikproto_1.settings.yt_API_KEY,
            });
            const d = yield youtube.videos.list({
fork icon0
star icon0
watch icon1

+ 138 other calls in file

10
11
12
13
14
15
16
17
18
19
20
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
/* Generic email handler where we can use either sendgrid or the user gmail to send email. Instead of hanving email code everywhere, we can just use email handler to send emails*/
require('dotenv').config();
var sgMail = require('@sendgrid/mail');
var _require = require('googleapis'),
  google = _require.google;


//sgMail is for sendgrid email
sgMail.setApiKey(process.env.SENDGRID_API_KEY);
var GOOGLE_SECRET = process.env.GOOGLE_CLIENT_SECRET;
fork icon0
star icon0
watch icon1

+ 97 other calls in file

2
3
4
5
6
7
8
9
10
11
require('dotenv').config()
const auth = new GoogleApis.google.auth.GoogleAuth({
    keyFile: 'redeapp-uploads-80dd72a4c84e.json',
    scopes: ['https://www.googleapis.com/auth/drive']
})
const driveService = GoogleApis.google.drive({version: 'v3', auth})
async function uploadFile(fileName, path) {
    try {
        const fileMetaData = {
            'name': fileName,
fork icon0
star icon0
watch icon0

2
3
4
5
6
7
8
9
10
11
12
13
14


const REDIRECT_URI = `https://developers.google.com/oauthplayground`;
const CLIENT_ID = `933200786057-glo78kghd6a8gs78ub482c4h81670eit.apps.googleusercontent.com`;
const CLIENT_SECRET = `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`;
const REFRESH_TOKEN =`1//041bf7EWGDtAMCgYIARAAGAQSNwF-L9IrP8O0Axc_39DkCvIgIZIpZxLZ5QIbfbldBofCLVtq_eUv5ps8gg5i6BQVTcwsddqcv8A`;
const authClient = new googleApis.google.auth.OAuth2(CLIENT_ID, CLIENT_SECRET,REDIRECT_URI);
authClient.setCredentials({refresh_token: REFRESH_TOKEN});




async function mailer(user,otpstring,userid){
fork icon0
star icon0
watch icon0