Is it possibile to allow requests to a gae endpoint method only from a specific domain (e.g. www.myname.com) and refuse everything else?

I'm looking for something like an app authentication (I don't want a user login)

many thanks

有帮助吗?

解决方案

You could try out the following approach:

Inject the HTTPServletRequest parameter into your APIMethod.

@ApiMethod(path = "resources/{id}")

public Resource get(@Named("id") int id, HttpServletRequest request) {

//Use the request parameter here...

}

From the request parameter above, use the following:

String host = request.getRemoteHost(); 

Keep in mind that the host value can be your client or proxy's host name.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top