【发布时间】:2019-02-03 02:48:48
【问题描述】:
我收到了一封来自 Google 的电子邮件,警告我我的 Google App Script 项目将受到即将关闭的(2019 年 1 月 28 日至 2019 年 3 月 7 日)Google+ API 关闭的影响。
您好 Google+ 开发者,
以下电子邮件包含您最近对 Google+ API 的使用情况。注意:它包括 Google+ OAuth 范围请求,这些请求也会受到 Google+ 关闭的影响。之前发送给活动 API 调用者的电子邮件未包含有关 OAuth 请求的信息。最后一封提醒电子邮件将在 2 月份发送给仍有活跃 API 或 OAuth 请求活动的用户。
我需要知道什么? 2019 年 3 月 7 日,所有 Google+ API 和 Google+ 登录将完全关闭。这将是逐步关闭,API 调用最早在 2019 年 1 月 28 日开始间歇性失败,而对 Google+ 范围的 OAuth 请求最早在 2019 年 2 月 15 日开始间歇性失败。
我需要做什么? 请在 2019 年 3 月 7 日之前更新您的下列项目,并确保它们不再使用 Google+ API 或请求 Google+ OAuth 范围。下面的数据显示了您的项目最近调用了哪些 Google+ API 方法,以及它请求的 Google+ OAuth 范围。 注意:如果您看到对 people.get 的调用,这可能是在您的应用程序中使用 Google+ 登录功能的结果,该功能现已完全弃用并正在关闭。开发者应该从 Google+ 登录功能迁移到更全面的 Google 登录身份验证系统。
这封电子邮件明确说明了我的项目中的故障,并提供了以下位置详细信息:
Project...............:My_GAS_Project_Name
Google+ API Name......:OAuth
Version...............:N/A
Method or OAuth Scope.:plus.me
但我认为这是误报。
我使用的是 OAuth API,而不是 Google+ API。我搜索了以下字符串; “加号”和“+”在我的代码中,并没有在任何地方找到引用*。
*是的,到处都有“+”,但每个人都被视为字符串连接操作。
这是项目中的OAuth功能:
function _getAuthenticationToken_() {
// Check we have access to the service
var service = getService();
if (!service.hasAccess()) {
var authorizationUrl = service.getAuthorizationUrl();
_log_('INFO', 'Open the following URL and re-run the script: ' + authorizationUrl);
return;
}
Logger.log('Passed Authentication');
//Get the Access Token
return service.getAccessToken();
function getService() {
// Create a new service with the given name. The name will be used when
// persisting the authorized token, so ensure it is unique within the
// scope of the property store.
return OAuth2.createService('jlr-edw-dev-service')
// Set the endpoint URLs, which are the same for all Google services.
.setAuthorizationBaseUrl('https://accounts.google.com/o/oauth2/auth')
.setTokenUrl('https://accounts.google.com/o/oauth2/token')
// Set the client ID and secret, from the Google Developers Console.
.setClientId(CLIENT_ID)
.setClientSecret(CLIENT_SECRET)
// Set the name of the callback function in the script referenced
// above that should be invoked to complete the OAuth flow.
.setCallbackFunction('authCallback')
// Set the property store where authorized tokens should be persisted.
.setPropertyStore(PropertiesService.getUserProperties())
// Set the scopes to request (space-separated for Google services).
// this is admin access for the sqlservice and access to the cloud-platform:
.setScope(
'https://www.googleapis.com/auth/sqlservice.admin ' +
'https://www.googleapis.com/auth/cloud-platform')
//Removed because this Should be covered by cloud-platform
//'https://www.googleapis.com/auth/devstorage.read_write '
// Below are Google-specific OAuth2 parameters.
// Sets the login hint, which will prevent the account chooser screen
// from being shown to users logged in with multiple accounts.
.setParam('login_hint', Session.getActiveUser().getEmail())
// Requests offline access.
.setParam('access_type', 'offline')
// Forces the approval prompt every time. This is useful for testing,
// but not desirable in a production application.
.setParam('approval_prompt', 'force');
}
function authCallback(request) {
var cloudSQLService = getService();
var isAuthorized = cloudSQLService.handleCallback(request);
if (isAuthorized) {
_log_('INFO', 'Access Approved');
return HtmlService.createHtmlOutput('Success! You can close this tab.');
} else {
_log_('INFO', 'Access Denied');
return HtmlService.createHtmlOutput('Denied. You can close this tab');
}
}
}
我应该忽略来自 Google 的警告,还是我可以检查其他任何东西来确认这些项目没有风险?
我应该补充一点,这些项目是通过 Google App Script Execution API 公开的,并且它们的功能是通过 Java program based on the the Google example 执行的。只有以这种方式访问的项目才被标记。
更多细节添加以回应 DaImTo 的评论。
Google+ API 和 People API 均已关闭:
更新
1) 这些是从用于执行 Google 应用脚本的 Java 程序中提取的范围。它们包括范围“https://www.googleapis.com/auth/userinfo.email”。
2) 这是Google OAuth2 API, v2 范围文档。
3) 这些是授予 Google App Script 项目的范围。根据描述性名称,“plus.me”似乎已包含在内,即“知道您在 Google 上的身份 = https://www.googleapis.com/auth/plus.me”。
因此,由于某种原因,在请求访问“https://www.googleapis.com/auth/userinfo.email”时,请求被扩展为包括“https://www.googleapis.com/auth/plus.me”。我认为这可能是因为“serinfo.email”已被弃用,described here。
已解决
来自 Google 的进一步沟通表明这确实是误报,不需要更改代码。
尊敬的开发者,
本周早些时候,我们向您发送了一封与您的项目相关的电子邮件,这些项目将受到 Google+ API 关闭的影响,这也会影响对 Google+ OAuth 范围的请求。
电子邮件列出了您的一个或多个项目正在请求“plus.me”范围,因此会受到影响。我们想澄清的是,只有直接请求“plus.me”范围的项目才会受到影响。即使您的项目没有直接要求,此范围可能已在某些电子邮件中列出。对于造成的任何混乱,我们深表歉意。
如果您直接请求“plus.me”范围、任何其他 Google+ OAuth 范围或进行任何 Google+ API 调用,请确保在 2019 年 3 月 7 日之前从您的项目中删除这些请求。
查看您的项目是否直接请求“plus.me”或任何其他 Google+ OAuth 范围:
• 如果您的项目是用 Google Apps 脚本编写的,您可以通过在应用脚本编辑器中查看您的项目属性来查看您的项目请求的范围。
• 如果您的项目不是用 Google Apps 脚本编写的,请检查您的代码以获取 OAuth 范围请求中对“plus.me”的引用。我们建议您使用任何支持登录或社交功能的第三方库来审核项目,因为这些库也可能会受到关闭的影响。
感谢您成为重要的 Google+ 开发者。
真诚地, Google+ API 团队
【问题讨论】:
标签: google-apps-script oauth-2.0 google-api google-plus google-oauth