I want to secure an API on App Engine, so that it can only be accessed from another server (which is hosted off App Engine).
Google explains this here https://cloud.google.com/appengine/docs/java/endpoints/consume_js#adding_authentication_support_with_oauth_20 but only shows how I can use a client id to secure my API for proprietary access by Android, iOS and Webbrowsers/Javascript gapi.
I assume that if I want to access the API server-to-server using REST, I will need to create a "Client ID for web application" in the App Engine console, then specify the client id in the endpoint annotation...
@Api(
name = "api",
description = "API",
namespace = @ApiNamespace(ownerDomain = "domain.com", ownerName = "Ownername")
clientIds = { "clientidgoeshere" }
)
... and add the user parameter to the endpoint:
public void restMethodName(
@Named("serverurl") String serverUrl, // whatever parameters
final com.google.appengine.api.users.User auth
) throws ServiceException, OAuthRequestException {
if (auth == null) throw new OAuthRequestException("Unauthorized error message.");
// ...
}
I believe this is fine so far. If the server-side implementation is incorrect, tell me why.
Now my problem: I don't have any idea how I must prepare and pass the user parameter to the App Engine cloud endpoints framework for authentication.
I am looking for a solution which I can generically use from any language, without using the generated Cloud Endpoints jar library which is typically used on Android, only.
Please describe what I need to wrap or sign (probably the client secret) and where I need to place it in my https request (probably in the parameters), or tell me where the whole Cloud Endpoints security workflow is properly documented.