-
Notifications
You must be signed in to change notification settings - Fork 0
/
webmaster.js
31 lines (27 loc) · 842 Bytes
/
webmaster.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const path = require('path');
const {google} = require('googleapis');
// const {authenticate} = require('@google-cloud/local-auth');
const webmasters = google.webmasters('v3');
async function runSample() {
// Obtain user credentials to use for the request
// const auth = await authenticate({
// keyfilePath: path.join(__dirname, 'api_keys.json'),
// scopes: [
// 'https://www.googleapis.com/auth/webmasters',
// 'https://www.googleapis.com/auth/webmasters.readonly',
// ],
// });
// google.options({auth});
const res = await webmasters.searchanalytics.query({
siteUrl: 'http://jbeckwith.com',
requestBody: {
startDate: '2018-01-01',
endDate: '2018-04-01',
},
});
console.log(res.data);
return res.data;
}
if (module === require.main) {
runSample().catch(console.error);
}