新的 google hangouts chat 的文档说你需要授权范围https://www.googleapis.com/auth/chat.bot来做几乎任何事情。
这是错误:
使用他们的OAuth2 客户端生成身份验证 URL 时,我收到范围无效的消息。如果我使用https://www.googleapis.com/auth/chat或其他类似google plus的范围,我就没有这个问题。
当我尝试在API Explorer中搜索内容时,URL 或部分 URL 的组合也不起作用。
这是我获取 URL 的代码,似乎适用于其他所有内容:
var {google} = require('googleapis');
var OAuth2 = google.auth.OAuth2;
var oauth2Client = new OAuth2(
"clientid-idididid.apps.googleusercontent.com",
"_secretsuff",
"http://localhost:3000/auth/google/callback"
);
var scopes = [
"https://www.googleapis.com/auth/chat", //Works
"https://www.googleapis.com/auth/chat.bot" // Does not work
];
var url = oauth2Client.generateAuthUrl({
access_type: 'offline',
scope: scopes,
});
console.log(url);