Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const {google} = require('googleapis');
- const oauth2Client = new google.auth.OAuth2(
- process.env.CLIENT_ID,
- process.env.CLIENT_SECRET,
- process.env.REDIRECT_URL
- );
- const webmasters = google.webmasters({
- version: 'v3',
- auth: oauth2Client,
- });
- async function runSample() {
- const res = await webmasters.searchanalytics.query({
- siteUrl: 'https://andsafe.de',
- requestBody: {
- startDate: '2019-01-01',
- endDate: '2019-04-01',
- },
- });
- console.log(res.data);
- return res.data;
- }
- const url = oauth2Client.generateAuthUrl({
- // 'online' (default) or 'offline' (gets refresh_token)
- access_type: 'offline',
- scope: "https://www.googleapis.com/auth/webmasters.readonly"
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement