Appengine: call endpoints of another module on the same server <p>I am working on an App Engine server which has currently 2 modules. I have the default module used for endpoints and the sync module. This second module is used for syncing my server with another. So my sync module gets data from other servers and has to send it to the default module using endpoints. To do this, I generated endpoints_client_library and added the library to my sync module. I tried a lot of cases but I can't communicate my endpoints properly. Each times I got errors like "401 Unauthorized". </p> <p>So I don't know if it's the right way to use the generated endpoints client library on my server or if there is another solution, maybe simplier...</p> <p>I just want to send data from my sync module to the default.</p> <p>If you need some code, even if it is not very complete and not working at all, just say and I will.</p> <p>The URLFetch code I'm using:</p> <pre><code>AppIdentityService appIdentity = AppIdentityServiceFactory.getAppIdentityService(); AppIdentityService.GetAccessTokenResult accessToken = appIdentity.getAccessToken(Collections.singleton(scope)); URLFetchService fetcher = URLFetchServiceFactory.getURLFetchService(); FetchOptions options = FetchOptions.Builder.doNotFollowRedirects().disallowTruncate(); HTTPRequest request = new HTTPRequest(url, HTTPMethod.GET, options); HTTPHeader userAgent = new HTTPHeader("User-Agent", "AppEngine-Google; (+http://code.google.com/appengine; appid: appId)"); request.addHeader(userAgent); HTTPHeader autho = new HTTPHeader("Authorization", "OAuth "+accessToken.getAccessToken()); request.addHeader(autho); HTTPHeader contentType = new HTTPHeader("Content-Type", "application/json"); request.addHeader(contentType); HTTPResponse response = fetcher.fetch(request); int code = response.getResponseCode(); String resp = new String(response.getContent()); System.out.println(code); System.out.println(resp); </code></pre> <p>And the result: </p> <p>401</p> <pre><code>{ "error": { "errors": [ { "domain": "global", "reason": "required", "message": "{\"class\":\"com.domain.server.cloud.CloudException\",\"code\":2}", "locationType": "header", "location": "Authorization" } ], "code": 401, "message": "{\"class\":\"com.domain.server.cloud.CloudException\",\"code\":2}" } } </code></pre>