从 Compute Engine 与 App Engine 通信的安全方式
Secure way to communicate with App Engine from Compute Engine
有一种内置的方法来设置 oauth on App Engine side, and it works great for request coming from my local machine with token generated by GoogleCredentials.get_application_default(),但它不适用于来自 Compute Engine 的请求,在 App Engine 端出现 NotAllowedError
异常。
我多次尝试配置请求范围以将 https://www.googleapis.com/auth/userinfo.emails
作为必需的范围包括在内,但没有成功。
事实证明,当您使用 Allow API access to all Google Cloud services in the same project.
创建实例时,它 不 包含所需的用户信息范围。
要包含用户信息范围,您必须取消选中 Allow API access to all Google Cloud services in the same project.
,转到 Access & Security
选项卡并明确启用用户信息范围。
更新 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
有一种内置的方法来设置 oauth on App Engine side, and it works great for request coming from my local machine with token generated by GoogleCredentials.get_application_default(),但它不适用于来自 Compute Engine 的请求,在 App Engine 端出现 NotAllowedError
异常。
我多次尝试配置请求范围以将 https://www.googleapis.com/auth/userinfo.emails
作为必需的范围包括在内,但没有成功。
事实证明,当您使用 Allow API access to all Google Cloud services in the same project.
创建实例时,它 不 包含所需的用户信息范围。
要包含用户信息范围,您必须取消选中 Allow API access to all Google Cloud services in the same project.
,转到 Access & Security
选项卡并明确启用用户信息范围。
更新 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