How to get a list of authenticated users in app engine cloud endpoints?
-
21-12-2019 - |
Question
Im using Cloud Endpoints on App Engine to have authenticated endpoints in my backend. What I would like to do is have a Users table in my backend datastore that contains a list of users that have authenticated with my app. Is there someway to create and retrieve this list of users? I figure I would need a callback everytime someone authenticates so I could add them to the datastore. Or is this something app engine gives you out of the box somehow?
Solution
Since you have used authentication in your Cloud Endpoints, you must have injected the User
object in your API methods.
This object will get automatically populated by the infrastructure service and you can use that to get more information about User. Once you have that information, you will need to manage your own Datastore collection of such users.