gpt4 book ai didi

node.js - 哪些 Google 域验证 API 用于 Pub/Sub 域验证?

转载 作者:搜寻专家 更新时间:2023-10-30 21:46:47 24 4
gpt4 key购买 nike

我有这段代码,它获取域 token 并使用 Site Verification API 验证谷歌域:

const auth = await this.gcp.getApplicationCredential(accountId, projectId,[
'https://www.googleapis.com/auth/siteverification',
'https://www.googleapis.com/auth/siteverification.verify_only'
]);
const siteVerification = this.google.siteVerification({
version: 'v1',
auth
});
const res = await siteVerification.webResource.getToken({
requestBody: {
verificationMethod: "FILE",
site: {
identifier: siteUrl,
type: "SITE"
}
}
});
await siteVerification.webResource.insert({
verificationMethod: "FILE",
requestBody: {
site: {
identifier: siteUrl,
type: "SITE",
},
}
});

执行此操作后,我可以在 UI 中看到该站点已验证: enter image description here

然后我使用 Search Console API将站点添加到搜索控制台:

const auth = await this.gcp.getApplicationCredential(accountId, projectId,[
'https://www.googleapis.com/auth/webmasters'
]);
const webVerification = this.google.webmasters({
version: 'v3',
auth
});
await webVerification.sites.add({
siteUrl
});

当我像这样对 API 执行 GET 操作时:

const site = await webVerification.sites.get({
siteUrl
});

我可以看到我的 API 调用成功了:

{
“siteUrl”: “https://fakewebsite.com/“,
“permissionLevel”: “siteOwner”
}

问题是: 当我查看项目中的 UI 时,我没有看到验证: enter image description here当我尝试使用推送端点创建订阅时,我的 API 调用失败了:

await pubsub.projects.subscriptions.create({
name: subscription,
requestBody: {
topic: topicName,
pushConfig: {
pushEndpoint
},
}
});

出现此错误:

{"errorType":"Error","errorMessage":"The supplied HTTP URL is not registered in the subscription's parent project (url=\"https://fakewebsite.com/c050d966-b62c-4cc8-9cc9-d431e8d8f14c/suggestions\", project_id=\"9999999999\").

有人知道我做错了什么吗?

最佳答案

我今天从 Google Iam 工程团队那里得到了这个问题的答案。 Google Cloud 目前没有用于域验证的 API。它必须通过 UI 完成。他们确实为我提交了功能请求,所以如果可用,我会更新。

关于node.js - 哪些 Google 域验证 API 用于 Pub/Sub 域验证?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53734528/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com