【问题标题】:get current user with java in Google apps Marketplace在 Google Apps Marketplace 中使用 java 获取当前用户
【发布时间】: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


【解决方案1】:

我建议您使用Google Java Client 库和App Engine support。有一个 specific sample 演示了如何在带有云存储的 App Engine 上使用服务帐户,但是对于您计划使用的任何 api(例如 Admin SDK),该技术应该是相同的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多