如何列出已添加到Search Console的网站/属性

问题描述

我想添加新的站点/属性,并使用googleapis列出现有站点/属性

首先,我尝试列出现有的,但得到的结果为空。

我当前使用的代码是这样:

const {google} = require('googleapis')

const ScopES = ['https://www.googleapis.com/auth/webmasters']

const key = require('./config/credentials.json')
const jwtClient = new google.auth.JWT(
  key.client_email,null,key.private_key,ScopES
)

jwtClient.authorize(function (err,token) {
  if (err) {
    console.log(err)
  }
})

function list () {
  const webmasters = google.webmasters({
    version: 'v3',auth: jwtClient
  })
  
  let wb = webmasters.sites.list({})
    .then(function (res) {
      console.log(res.data)
    }).catch(function (err) {
      console.log(err)
    })
}

list()

并且console.log(res.data);记录{}。有谁知道如何正确列出所有姿势/属性

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)