Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
!this.googleAssistant.config.transactions ||
!this.googleAssistant.config.transactions.keyFile
) {
throw new JovoError(
'Please add a valid keyFile object to the GoogleAssistant transaction config',
ErrorCode.ERR,
'jovo-platform-googleassistant',
);
}
/**
* DigitalGoods.ts needs the googleapis package to function.
* To reduce overall package size, googleapis wasn't added as a dependency.
* googleapis has to be manually installed
*/
try {
const googleapis = require('googleapis').google;
return googleapis.auth
.getClient({
keyFile: this.googleAssistant.config.transactions!.keyFile,
scopes: ['https://www.googleapis.com/auth/actions.purchases.digital'],
})
.then((client: any) => client.authorize()) // tslint:disable-line
.then((authorization: any) => authorization.access_token as string); // tslint:disable-line
} catch (e) {
console.log(e);
console.log(e.stack);
if (e.message === "Cannot find module 'googleapis'") {
return Promise.reject(
new JovoError(
e.message,
ErrorCode.ERR,
var fs = require('fs');
var readline = require('readline');
var google = require('googleapis').google;
var OAuth2 = google.auth.OAuth2;
// If modifying these scopes, delete your previously saved credentials
// at ~/.credentials/drive-nodejs-quickstart.json
var SCOPES = ['https://www.googleapis.com/auth/drive.file'];
var ENV_FILE_PATH = '.env';
let secrets;
// Load client secrets from a local file.
fs.readFile('client_secret.json', function processClientSecrets(err, content) {
if (err) {
console.log('Error loading client secret file: ' + err);
return;
}
// Authorize a client with the loaded credentials, then call the
// Drive API.
return __awaiter(this, void 0, void 0, function* () {
// getting server to server OAuth token
const serviceAccountAuth = new googleapis_1.google.auth.JWT({
email: cred.client_email,
key: cred.private_key,
scopes: ['https://www.googleapis.com/auth/cloud-platform', 'https://www.googleapis.com/auth/dialogflow']
});
const tokenData = yield serviceAccountAuth.authorize();
console.log("tokenData: ", tokenData);
const accessToken = `${tokenData.token_type} ${tokenData.access_token}`;
console.log("accessToken: ", accessToken);
return new Promise((resolve, reject) => {
// adding all organizations in apiai userEntity
request.post({
url: `https://dialogflow.googleapis.com/v2/projects/${cred.project_id}/agent/sessions/${sessionId}:detectIntent`,
json: {
"queryInput": {
"text": {
"languageCode": "en",
// Add a sheet to be used as a storage
const Storage = require("../models/storage"),
googleAuthLib = require("google-auth-library"),
googleOAuthConfig = require("../helpers/authentication/configuration").google,
{ google } = require("googleapis");
module.exports = (req, res, next) => {
const sheets = google.sheets("v4"),
oauth2Client = new googleAuthLib.OAuth2Client(
googleOAuthConfig.clientID,
googleOAuthConfig.clientSecret,
googleOAuthConfig.callbackURL
);
oauth2Client.credentials = {
access_token: req.user.accessToken,
refresh_token: req.user.refreshToken
};
return sheets.spreadsheets
const _ = require('lodash');
const google = require('googleapis').google; // eslint-disable-line prefer-destructuring
class YouTube {
constructor(configuration) {
this.configuration = configuration;
this.scopes = ['https://www.googleapis.com/auth/youtube.readonly'];
this.youtube = google.youtube({
version: 'v3',
auth: this.configuration.YOUTUBE_API_KEY,
});
}
getLatestUploadedVideo() {
return this.getListOfUploadedVideos().then(response => response.items[0]);
}
getListOfUploadedVideos() {
const googleAuthLib = require("google-auth-library"),
googleOAuthConfig = require("../helpers/authentication/configuration").google,
{ google } = require("googleapis");
// result argument is what db returned on query
module.exports = (validUser, result, query, rowLimit = Infinity) => {
const sheets = google.sheets("v4"),
oauth2Client = new googleAuthLib.OAuth2Client(
googleOAuthConfig.clientID,
googleOAuthConfig.clientSecret,
googleOAuthConfig.callbackURL
);
oauth2Client.credentials = {
access_token: validUser.accessToken,
refresh_token: validUser.refreshToken
};
const imageDownloader = require('image-downloader')
const google = require('googleapis').google
const customSearch = google.customsearch('v1')
const state = require('./state.js')
const googleSearchCredentials = require('../credentials/google-search.json')
async function robot() {
console.log('> [image-robot] Starting...')
const content = state.load()
await fetchImagesOfAllSentences(content)
await downloadAllImages(content)
state.save(content)
async function fetchImagesOfAllSentences(content) {
for (let sentenceIndex = 0; sentenceIndex < content.sentences.length; sentenceIndex++) {
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(require("@actions/core"));
const fs = __importStar(require("fs"));
const fs_1 = require("fs");
const googleapis_1 = require("googleapis");
const androidPublisher = googleapis_1.google.androidpublisher('v3');
function uploadRelease(options, releaseFile) {
return __awaiter(this, void 0, void 0, function* () {
const appEdit = yield androidPublisher.edits.insert({
auth: options.auth,
packageName: options.applicationId
});
const allTracks = yield getAllTracks(appEdit.data, options);
if (allTracks == undefined || allTracks.find(value => value.track == options.track) == undefined) {
core.setFailed(`Track "${options.track}" could not be found `);
return Promise.reject(`No track found for "${options.track}"`);
}
let track = undefined;
if (releaseFile.endsWith('.apk')) {
const apk = yield uploadApk(appEdit.data, options, releaseFile);
yield uploadMappingFile(appEdit.data, apk.versionCode, options);
track = yield trackVersionCode(appEdit.data, options, apk.versionCode);
return m.bind(_this);
}));
_defineProperty(this, "drive", mapValues(driveMethods, function (m) {
return m.bind(_this);
}));
_defineProperty(this, "sheets", mapValues(sheetsMethods, function (m) {
return m.bind(_this);
}));
_defineProperty(this, "docs", mapValues(docsMethods, function (m) {
return m.bind(_this);
}));
this.sheetsAPI = googleapis.google.sheets('v4');
this.driveAPI = googleapis.google.drive('v3');
this.docsAPI = googleapis.google.docs('v1');
};
install(googleAssistant: GoogleAssistant) {
/**
* Notification.ts needs the googleapis package to function.
* To reduce overall package size, googleapis wasn't added as a dependency.
* googleapis has to be manually installed
*/
try {
this.google = require('googleapis').google;
} catch (e) {
if (e.message === "Cannot find module 'googleapis'") {
throw new JovoError(
e.message,
ErrorCode.ERR,
'jovo-platform-googleassistant',
undefined,
'Please run `npm install googleapis`',
);
}
}
googleAssistant.middleware('$type')!.use(this.type.bind(this));
GoogleAction.prototype.$notification = undefined;
GoogleAction.prototype.notification = function() {