Yes, Deniz, I believe so, but just to be sure we are talking about the same "user ID" or more precise, how it is extracted: For Cloud Endpoints handlers in App Engine the implementation can be really simple and safe. If you implement the handler in Node.js (flexible environment) your handler reads the request's HTTP header
X-Endpoint-API-UserInfo to retrieve current user information as JSON object, including the user ID. I assume that's what you intent to implement and you can rely on the user information retrieved from this header (see earlier reply by Katayoon). If you intent to use the
Authorization header instead, read my PS below. You might want your implementation to also check if the hosted domain is the same as a particular G Suite domain though, or apply whatever custom access control you need additionally (roles, custom claims etc.).
Other than that, as always keep tight control of user access to your GCP resources (via IAM in Cloud Console) and an eye on
Audit Log, and you should be safe.
PS: Theoretically, your handler could (instead of
X-Endpoint-API-UserInfo) access the original HTTP
Authorization header of the request (if I remember correctly, Cloud Endpoints ESP/OpenAPI makes it available to the handler) to validate the ID token and extract user information. But safely validating a JSON Web Token (JWT)
is not trivial, hence that anyone could send a fake ID token to your endpoint. Therefor I assume that's not what you plan to do. Handlers outside of Cloud Endpoints or even outside of App Engine might need to (partially) implement their own token validation, but I would avoid this wherever I can. For everyone who is interested: a very general platform-agnostic documentation is provided by Google Identity Platform:
OpenID Connect - Validating an ID Token.