[英]AppEngine Endpoints HTTP Cookies
I am trying to read out the HTTP Cookies from AppEngine Endpoints method: 我正在尝试从AppEngine Endpoints方法中读取HTTP Cookie:
@ApiMethod(httpMethod = "get")
public void getAll(HttpServletRequest req) {
log.info("req: " + req);
Cookie[] cookies = req.getCookies();
for (Cookie cookie : cookies) {
log.info("cookie: " + cookie.getName() + " " + cookie.getValue());
}
}
But no matter what i try, the cookies are NULL. 但是无论我尝试什么,cookie都是NULL。 Any ideas?
有任何想法吗? It should work in this way: http://chirashi.zenconsult.net/2013/07/custom-authentication-with-google-cloud-endpoints-using-app-engine-java
它应该以这种方式工作: http : //chirashi.zenconsult.net/2013/07/custom-authentication-with-google-cloud-endpoints-using-app-engine-java
Something like this seems to work for me. 这样的事情似乎对我有用。 I have tested it right on App Engine.
我已经在App Engine上对其进行了测试。
@Api(name = "api_name", version = "v1", description = "An API", auth = @ApiAuth(allowCookieAuth = AnnotationBoolean.TRUE))
It doesn't seem to work with Java. 它似乎不适用于Java。 There's a bug filed here: https://code.google.com/p/googleappengine/issues/detail?id=10100
此处存在一个错误: https : //code.google.com/p/googleappengine/issues/detail?id=10100
With Python, cookies aren't passed through by default but there is a way to enable them . 使用Python,默认情况下不会通过cookie,但是有一种启用它们的方法 。 I think this annotation is meant to do the same in Java but doesn't seem to do anything:
我认为这个注解在Java中打算做同样的事情,但似乎什么也没做:
@ApiAuth(allowCookieAuth = AnnotationBoolean.TRUE)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.