App Engine灵活+应用程序标识(Python) [英] App Engine Flexible + App Identity (Python)
问题描述
有没有办法从google.appengine.api移植
的功能从Google导入app_identity
.appengine.api在灵活环境中导入urlfetch
我有一个服务在Flex环境中运行,需要向标准环境发出请求,并且想要使用App Engine的本机应用程序标识和 看起来,如果请求的来源是来自标准环境,则标题会传递到flex环境,但而不是其他方式? 原文: 应用程式标识: 在灵活的环境中运行,您可以使用 应用程序/项目ID GCLOUD_PROJECT 元数据服务器中的 / project / project-id 资源 至于urlfetch移植,来自网址提取: 灵活的环境没有沙箱限制,因此您可以使用任何HTTP库 因此,请检查具体的方法,为您决定使用的任何HTTP库设置响应头。 Is there a way to port the functionality of in the flexible environment? I have a service running on the flex environment which needs to make a request to the standard environment and would like to use App Engine's native app identity and It seems that if the origin of the request is from the standard environment, the header is passed on to the flex environment but not the other way around? Update: It is not possible to use the Original post: From App identity: When running on the flexible environment, you can use a combination of
environment variables and the Google Compute Engine Metadata
service to obtain information about your application: Application / project ID Either the GCLOUD_PROJECT environment variable or
the /project/project-id resource in the metadata server So you could try to get the app ID in the flex env service as mentioned above and manually set the As for the urlfetch porting, from URL Fetch: The flexible environment has no sandbox restrictions, so you can use
any HTTP library. We recommend using Requests. So check for the specific method to set the response header for whichever HTTP library you decide to use. 这篇关于App Engine灵活+应用程序标识(Python)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! X-Appengine-Inbound-Appid <
$ b> b $ p
$ b X-Appengine-Inbound-Appid
头部,因为正如你所看到的那样,它在标准env服务的入口侧被移除,因为在灵活的出口侧被特别设置env服务,按照建议实验:
环境变量和 Google计算引擎元数据
服务以获取有关您的应用程序的信息:
<因此,您可以尝试在flex env服务中获取应用程序标识,如上所述e并手动设置 X-Appengine-Inbound-Appid
响应标题。不能在标准env服务的入口端删除
。我们建议您使用请求。
from google.appengine.api import app_identity
from google.appengine.api import urlfetch
X-Appengine-Inbound-Appid
header to do so.X-Appengine-Inbound-Appid
header in this case because, as you observed, it is removed on the ingress side of the standard env service after being specifically set on the egress side of the flexible env service, following the suggested experiment:
X-Appengine-Inbound-Appid
response header. It might not be removed on the ingress side of the standard env service (it's not explicitly mentioned to be removed in Request headers).