我尝试按照以下说明以编程方式提交sitemap.xml: https://developers.google.com/webmaster-tools/search-console-api-original/v3/sitemaps/submit#auth
我做:
// Just call this once to set JWT
HTTPJWT.setJWTOptions({
email : "[ client ID up to the first dot ]@developer.gserviceaccount.com",
key : Assets.getText("key.pem"), // Get key file from assets
scopes : [
"https://www.googleapis.com/auth/webmasters"
],
});
var submitUrl = "https://www.googleapis.com/webmasters/v3/sites/https%3A%2F%2Fwww.spoticle.com/sitemaps/https%3A%2F%2Fwww.spoticle.com%2Fsitemap.xml";
var result = HTTPJWT.get(submitUrl);
......结果如下:
错误:失败[400] {"错误" :" invalid_grant"," error_description" :"无效的JWT签名。" }
然而,我可以通过以下方式生成JWT:
var jwt = GoogleOAuthJWT.encodeJWT({
email : "[ client ID up to the first dot ]@developer.gserviceaccount.com",
key : Assets.getText("key.pem"), // Get key file from assets
scopes : [
"https://www.googleapis.com/auth/webmasters"
]
});
...但我不知道如何验证此令牌是否有效。
任何帮助表示赞赏。感谢。