我目前正在使用Google Cloud Endpoint生成的JavaScript客户端对我的后端进行API调用。问题是我的页面的cookies没有被添加到HTTP请求中。我如何将Gitkit gtoken cookie添加到我的请求中。使用Google Cloud Endpoints JavaScript客户端时在HTTP请求中包含Cookie
- 后端是谷歌应用程序引擎的Java
- 使用古尔云端点建立我的API
- 使用加载了谷歌云端点JavaScript的Web客户端如下
gapi.client.load('myApi', 'v1', resourceLoaded, 'https://my-project-id.appspot.com/_ah/api');
我已经配置了谷歌云终端,在后端,允许cookie。 auth = @ApiAuth(allowCookieAuth = AnnotationBoolean.TRUE)
我的端点如下所示。
@ApiMethod(path = "user-account")
public UserAccount get(HttpServletRequest httpRequest) {
GitkitUser gitkitUser = Gitkit.validate(httpRequest); // returns null
Cookie[] cookies = httpRequest.getCookies();
log.severe("# of cookies: " + cookies.length);
for (Cookie cookie : cookies) {
log.severe("cookie name: " + cookie.getName());
log.severe("cookie value: " + cookie.getValue());
}
/*
* Logs 1 for # of cookies, with a cookie name of "G_ENABLED_IDPS"
* a value of "google". No gtoken cookie, even though I have
* checked and there is one!
*/
...
}
我正在使用Google Cloud Endpoints JS客户端拨打电话。
gapi.client.myApi.userAccountResource.get().execute(function (resp){
...
});
有什么我必须做的,以确保端点JS客户端包括在它的请求gtoken饼干吗?
打开赏金,仍然没有答案!有什么我可以做的,使这个问题更清楚? –
Hi Marc,你可以添加cookies存储+请求标题的屏幕截图,并创建一个plunker/jsfiddle/jsbin来重现问题。 –
@AlexanderTrakhimenok你的意思是浏览器端的cookie存储? –