Advertisement
Guest User

Untitled

a guest
Dec 13th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const {google} = require('googleapis');
  2.   const oauth2Client = new google.auth.OAuth2(
  3.     process.env.CLIENT_ID,
  4.     process.env.CLIENT_SECRET,
  5.     process.env.REDIRECT_URL
  6.   );
  7.  
  8.   const webmasters = google.webmasters({
  9.     version: 'v3',
  10.     auth: oauth2Client,
  11.   });
  12.  
  13.   async function runSample() {
  14.     const res = await webmasters.searchanalytics.query({
  15.       siteUrl: 'https://andsafe.de',
  16.       requestBody: {
  17.         startDate: '2019-01-01',
  18.         endDate: '2019-04-01',
  19.       },
  20.     });
  21.     console.log(res.data);
  22.     return res.data;
  23.   }  
  24.   const url = oauth2Client.generateAuthUrl({
  25.     // 'online' (default) or 'offline' (gets refresh_token)
  26.     access_type: 'offline',
  27.     scope: "https://www.googleapis.com/auth/webmasters.readonly"
  28.   });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement