Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Cloud Endpoint Backend - Is it possible to retrieve attributes of the HttpSession?

I'm trying to access the HttpSession object (or similar API that let me fetch session attributes) from inside of a Google Cloud Endpoints backend method...

Reading this answer I've learn that I can inject a HttpRequest object as a parameter.

What I'm trying to do is retrieve a facebook access token previously stored by a Servlet.

Within the Development Web Server I can retrieve the HttpSession and get the desired attribute:

@ApiMethod
public MyResponse getResponse(HttpServletRequest req) {
    String accessToken = (String) req.getSession().getAttribute("accessToken");
}

But, once I deploy my application to GAE, the retrieved access token is always null.

So is there a way to recover session attributes from inside api methods?

And if there isn't, how can I retrieve my access token from someplace else? Answers and comments in the mentioned question suggests the use of the data store, but I really can't think of a good natural candidate for a key... As far as GAE authentication mechanism is concerned my users aren't even logged in, I don't know how to retrieve the access_token of the current user from the Datastore / memcached or any other mechanism.

like image 728
Anthony Accioly Avatar asked Dec 10 '25 23:12

Anthony Accioly


1 Answers

I've filed a feature request to support sessions in production, as I can confirm it's not working right now.

For now, I recommend you continue passing the access token on subsequent requests in a header. Header information is similarly available through the injected HttpServletRequest.

like image 181
Dan Holevoet Avatar answered Dec 12 '25 11:12

Dan Holevoet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!