0
votes

I am developing a Google App Engine app with a Cloud Endpoint. My app uses OpenID to authenticate a user. Once the user has logged in, in the same session, there is a call to the endpoint. In the endpoint code I want to access the user service for the current logged in user. This works on the development server, but after deploy to Google the userService returns null to the getCurrentUser() call.

Can I get the current logged in user during a cloud endpoint execution?

1

1 Answers

3
votes

You can't use the UserService within an Endpoint method (at least not one called via /_ah/api). Getting the current user in Endpoints is done via injection in the method signature, e.g.:

public Score insert(Score score, User user)

The User object will be populated with either: a valid user object (if the token sent into the request is valid) or null (if not).

I'm not sure how your local test is succeeding, but what I've described is the expected behavior.