Is there a way to use Simple Access API (Developer Key) instead of oAuth2 key with Google Cloud Endpoint?
2 Answers
Extra fields in your protorpc
request object that aren't part of the definition are still stored with the request.
If you wanted to use a key
field as a query parameter, you could access it via
request.get_unrecognized_field_info('key')
even if key
is not a field in your message definition.
This is done in users_id_token.py
(the Auth part of the endpoints
library) to allow sending bearer_token
or access_token
as query parameters instead of as header values.
Unfortunately, the nice quota checking and other associated pieces that a "Simple API Access" key gives are not readily available. However, you could issue your own keys and manually check a key against your list and potentially check against quotas that you have defined.

- 9,993
- 1
- 42
- 61
-
1@bossylobster You know that AFAICT this is the only place on the entire interwebs that documents how to use the apiKey. – Shay Erlichmen Jan 23 '14 at 09:08
-
Sort of :) but this should be in the github cloud samples. – Shay Erlichmen Jan 25 '14 at 02:22
-
How would that work in Java? I don't see a `get_unrecognized_field_info()` or similar message there. – Drux Jun 27 '14 at 21:09
-
You would need the raw contents of the original unparsed request. – bossylobster Jun 28 '14 at 00:27
-
This is perfect! Now, is it possible to edit the generated API in iOS to send your additional hidden field? – Carlos Guzman Sep 25 '14 at 04:02
-
By the way. don't use the actual name 'key' for the field. 'key' is a name that google reserves for the API key that you can create in the project console and you'll get an error. I just prefixed key with my project codename. – Carlos Guzman Oct 01 '14 at 04:14
For those looking to use @bossylobster's answer in Java, use the the SO Answer here: Getting raw HTTP Data (Headers, Cookies, etc) in Google Cloud Endpoints
P.S. I tried to make this a comment in @bossylobster's answer, but I don't have the reputation to do that. Feel free to clean up this answer so that other's can follow the path