【发布时间】:2014-02-06 10:23:59
【问题描述】:
我正在使用 Java 和 Appengine 为 Google Apps Marketplace 开发应用程序。
我需要知道向我的应用发出请求的用户是否使用 Google 帐户登录。 如果是这种情况并且用户已登录,请使用带有“服务帐户”的 OAuth2 运行应用程序以进行 api 调用。 我想到的一种解决方案是使用:
<security-constraint>
<web-resource-collection>
<web-resource-name>any</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>*</role-name>
</auth-constraint>
</security-constraint>
在“web.xml”文件中。
但是,Google Apps Marketplace 经理告诉我,我不能使用这个系统。 我也不能使用 OAuth2 流(Web 应用程序的客户端 ID),因为如果管理员之前已接受此范围,则用户不需要接受范围。
你会使用什么替代品? 为什么我不能使用“”?
提前致谢和问候。
【问题讨论】:
-
为什么不使用 google User Api 来检查用户是否已登录 UserService userService = UserServiceFactory.getUserService(); com.google.appengine.api.users.User user = userService.getCurrentUser();
标签: java google-app-engine servlets google-apps-marketplace