Skip to content

Commit

Permalink
add generate_token_v2.js
Browse files Browse the repository at this point in the history
  • Loading branch information
hermanho committed Aug 30, 2022
1 parent 0d001d8 commit 04bf317
Show file tree
Hide file tree
Showing 3 changed files with 1,878 additions and 0 deletions.
25 changes: 25 additions & 0 deletions generate_token_v2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use strict'
const fs = require('fs')
const path = require('path')
const mkdirp = require('mkdirp')
const { authenticate } = require('@google-cloud/local-auth');
const config = require("./google_auth.json")

async function generate() {
const keyFilePath = path.resolve(__dirname, config.keyFilePath)
const client = await authenticate({
keyfilePath: keyFilePath,
scopes: [config.scope],
});

if (client.credentials && config.savedTokensPath) {
if (config.savedTokensPath) {
const tp = path.resolve(__dirname, config.savedTokensPath)
mkdirp(path.dirname(tp), () => {
fs.writeFileSync(tp, JSON.stringify(client.credentials))
console.log("Token is generated. check it. (ls -al)")
})
}
}
}
generate();
Loading

0 comments on commit 04bf317

Please sign in to comment.