John Britto
John Britto

Reputation: 457

How to get App Id from request Header in GAE application

I am trying to get the application id from requestHeader it's returning as Null. Google App Engine doc confirms that they will be adding the some details in the request header in that the application id also there but I am not getting.

Here is what I tried.

String XAppEngineAppId = request
                    .getHeader("X-Appengine-Inbound-Appid");
            logger.info("APPID::" + XAppEngineAppId);

Upvotes: 0

Views: 2123

Answers (2)

Lawrence Latif
Lawrence Latif

Reputation: 11

The X-Appengine-Inbound-Appid header is set only when called to apps hosted on the appspot.com domain.

Also if you are using the java.net API, you must set connection.setInstanceFollowRedirects(false); so that App Engine inserts the header automatically.

Documentation on this topic is available here: https://cloud.google.com/appengine/docs/standard/java/appidentity/#asserting_identity_to_other_app_engine_apps

Upvotes: 1

gipsy
gipsy

Reputation: 3859

You can use the App Identity Java API

https://cloud.google.com/appengine/docs/java/appidentity/

The application ID can be found using the ApiProxy.Environment.getAppId() method.

Upvotes: 0

Related Questions