云发布/订阅演示:403用户无权执行此操作。当尝试推送通知时

2024-05-08 09:09:34 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在学习Google Cloud Pub/Sub,并遵循此官方文档:Writing and Responding to Pub/Sub Messages - Python

当我将它部署到云上并尝试提交消息时, enter image description here 我得到以下错误:

An internal error occurred: 403 User not authorized to perform this action. (POST https://pubsub.googleapis.com/v1/projects/your-project-id/topics/your-topic:publish) See logs for full stacktrace.

我想是因为认证问题吧?任何帮助都将不胜感激。


Tags: andto文档cloud消息your官方部署
2条回答

以下是谷歌文档中的一些注释Troubleshooting 403 (Forbidden) error

If you get this error, do the following:

  • Make sure you've enabled the Google Cloud Pub/Sub API in the Cloud Platform Console.
  • Make sure that the principal making the request has the required permissions on the relevant Google Cloud Pub/Sub resources,
    especially if you are using Google Cloud Pub/Sub for cross-project
    communication.
  • If you're using Dataflow, make sure that both @cloudservices.gserviceaccount.com and the Compute Engine
    Service account -compute@developer.gserviceaccount.com
    have the required permissions on the relevant Google Cloud Pub/Sub
    resource. See Google Cloud Dataflow Security and Permissions for more information.
  • If you're using App Engine, check your project's Permissions page to see if an App Engine Service Account listed as an Editor. If it is not, add your App Engine Service Account as an Editor. Normally, the App Engine Service Account is of the form
    @appspot.gserviceaccount.com.

确保您正在使用的客户端被授权发布到Pub/Sub。请参见details here。如果您的客户机与主题属于同一个项目,则通常不需要额外的访问控制配置。确保您的客户是authenticated properly

相关问题 更多 >