google-api-nodejs-client
google-api-nodejs-client copied to clipboard
Service account credentials -- Cannot read property 'redirect_uris' of undefined at authenticate (.../node_modules/@google-cloud/local-auth/build/src/index.js:47:15)
- Is this a client library issue or a product issue? Yeap i have this authenticate method but went I try to enter to the URL the console show "TypeError: Cannot read property 'redirect_uris' of undefined"
const express = require('express')
const router = express.Router()
const apiGoogleAnalitics = config().apiGoogleAnalitics
const request = require("request")
const {
google
} = require('googleapis')
const {
authenticate
} = require('@google-cloud/local-auth')
const analytics = google.analytics('v3')
const analyticsreporting = google.analyticsreporting('v4');
const url = require('url')
const opn = require('open')
const destroyer = require('server-destroy')
const people = google.people('v1')
const {
Storage
} = require('@google-cloud/storage');
const axios = require('axios')
const urlParse = require('url-parse')
const queryParse = require('query-string')
// NOTE: Consulta4 V4
let Consulta4 = async function(req,res1) {
// Obtain user credentials to use for the request
const auth = await authenticate({
keyfilePath: path.join(__dirname, '../../config/agile-transport-315113-e07a24f24dce.json'),
scopes: 'https://www.googleapis.com/auth/analytics',
}, (err,data)=>{
console.log(err)
console.log(data)
});
google.options({
auth
});
// NOTE: Auth
const res = await analyticsreporting.reports.batchGet({
reportRequests: [{
viewId: "ga:241564074",
dateRanges: [{
startDate: "2021-01-01",
endDate: "yesterday"
}],
metrics: [{
expression: "ga:totalEvents"
}],
dimensions: [{
histogramBuckets: [null],
name: "ga:eventLabel"
}],
dimensionFilterClauses: [{
operator: "AND",
filters: [{
dimensionName: "ga:eventCategory",
not: true,
operator: "PARTIAL",
expressions: ["cta"]
}, {
dimensionName: "ga:eventLabel",
not: true,
operator: "BEGINS_WITH",
expressions: ["btn"]
}]
}],
samplingLevel: "DEFAULT"
}]
});
console.log(res.data);
return res1.send(res.data)
}
module.exports = {
Consulta4
}
Environment details
- OS: Linux ubuntu 20.04
- Node.js version: v14.17.3
- npm version:6.14.13
googleapisversion: "@google-cloud/local-auth": "^1.0.1", "@google-cloud/storage": "^5.11.0", "@googleapis/analytics": "^2.0.0", "@googleapis/docs": "^0.2.0", "googleapis": "^80.1.0"
Steps to reproduce
- config the sample code with credentials.
- try to run the code
- get the error
help please!!!!
@romarioVortex what is the format of the keyfile you point to with that path?
It should have a top level field of web or installed, which then has a field redirect_uris underneath it. This exception suggests to me that it does not have either of these top level fields.
To get the appropriate keys you should visit https://console.cloud.google.com/apis/credentials, and download a key under the heading OAuth 2.0 Client IDs.