Reputation: 607
I want my android apps will communicate with my app engine server. I want that only authenticated user (google users) can access my EndPoints Api and to be stored in appengine using PYTHON.
Here there is an example using java appengine:
https://developers.google.com/eclipse/docs/endpoints-addauth
I want to use the User object on the server side and to save it as, and not save only the email address.
As an example, my request object of the protorpc will :
MessageRequest(User user, ...)
and when the user signs in with its google account in the apps he will populate the User object (on the server) in case it is a valid google account and in case it's not a good one, he won't be able to access the API.
Thank you
Upvotes: 1
Views: 689
Reputation: 10164
You can do the same in Python using the endpoints
library:
from google.appengine.ext import endpoints
@endpoints.api(...)
class MyApi(...):
@endpoints.method(...)
def my_method(self, request):
current_user = endpoints.get_current_user()
if current_user is None:
# This will result in a 401
raise endpoints.UnauthorizedException('Invalid token.')
In order to do this, you need to specify audiences=
and allowed_client_ids=
in either your endpoints.api
decorator or endpoints.method
decorator for the authenticated method.
These values are described in the Endpoints auth docs.
Upvotes: 1