python - 从 Compute Engine 与 App Engine 通信的安全方式

标签 python google-app-engine oauth-2.0 google-compute-engine google-cloud-platform

有一种内置的设置方式 oauth在 App Engine 方面,它非常适合来 self 的本地计算机且具有 GoogleCredentials 生成的 token 的请求。 get_application_default (),但它不适用于来自 App Engine 端出现 NotAllowedError 异常的 Compute Engine 的请求。

我多次尝试将请求范围配置为包含 https://www.googleapis.com/auth/userinfo.emails 作为其必需的范围,但没有成功。

最佳答案

事实证明,当您使用允许 API 访问同一项目中的所有 Google Cloud 服务创建实例时,它包含所需的用户信息范围。

enter image description here

要包含“用户信息”范围,您必须取消选中允许 API 访问同一项目中的所有 Google Cloud 服务。,转到访问和安全选项卡并显式启用用户信息范围。

enter image description here

更新2018-11-15

现在设置电子邮件范围的正确方法是使用 gcloud 命令:

gcloud compute instances set-service-account INSTANCE-ID --zone=us-central1-f --service-account=PROJECT-ID-compute@developer.gserviceaccount.com --scopes https://www.googleapis.com/auth/userinfo.email,cloud-platform

关于python - 从 Compute Engine 与 App Engine 通信的安全方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34368039/

相关文章:

django - 通过 React-Native 从 Django OauthToolkit 获取请求 token

python - 如何删除 docker 镜像的多个标签(除了一个标签)

python - 如何从我用 Python 创建的文件导入模块?

java - 用GAE打包其他项目

security - HTTP 基本身份验证 + 访问 token ?

java - 如何允许 "/api/**"通过我的基本身份验证配置并进入 Spring Security 中的 oauth 配置

python - 在pytorch中的不同nn.Moules中共享参数

python - 从 OOP 的角度来看,拥有固定状态的对象有多糟糕?

python - GAE & lxml : cleaning HTML but not style attribute

google-app-engine - App Engine 切换到高复制