我正在尝试按如下方式访问Java Servlet中的App Engine用户配置文件。
Your connection is not private
Attackers might be trying to steal your information from example.com (for example, passwords, messages, or credit cards). NET::ERR_CERT_AUTHORITY_INVALID
Automatically report details of possible security incidents to Google. Privacy policy
每当访问用户数据时,都会抛出OAuthRequestException。相同的代码在开发模式下工作,但不在部署模式下工作。
我无法理解为什么会抛出错误。据我所知,所需的权限可以在在线文档中说明(我猜!)。
答案 0 :(得分:0)
当请求不是有效的OAuth请求时,抛出OAuthRequestException。 这个link有一些例子,例如:
String scope = "https://www.googleapis.com/auth/userinfo.email";
try {
user = oauth.getCurrentUser(scope);
} catch (OAuthRequestException e) {
log("Impossible to authenticate the request from the image resizer, oauth request exception: "
+ e.getMessage());
resp.setStatus(HttpStatusCodes.STATUS_CODE_UNAUTHORIZED);
return;
}
答案 1 :(得分:0)
通过调用UserService
获取当前User
来解决错误。然而,同样不适用于开发模式。可能是来自Google App Engine团队的人可以解释一下!
UserService userService = UserServiceFactory.getUserService();
user = userService.getCurrentUser();
if (user == null) {
res.sendRedirect(userService.createLoginURL(req.getRequestURI()));
return;
}