1

I have had very bad experiences with googleapis, lost one week but failed so I open questions to find the help of everybody.

After creating a topic & subscription (with endpoint URL) from PUB/SUB of Google Cloud Flatform Console, I used nodejs with code bellow :

var gmail = google.gmail({ auth: {---my auth---}, version: 'v1' });

gmail.users.watch({
    userId: "me",
    resource: {
        topicName: "projects/responsive-hall-xxxx/topics/xxxx",
        labelIds: ["INBOX"]
    }
}

But got the error 403:

{ 
       domain: 'global',
       reason: 'forbidden',
       message: 'Error sending test message to Cloud PubSub projects/responsive-hall-xxxx/topics/xxxx : User not authorized to perform this action.'
}

I tried to set permissions for my gmail account on the pub/sub but still unsuccess.

Please help, Thanks!

Nguyen Tu
  • 101
  • 1
  • 4

2 Answers2

1

Have you granted publish permission to serviceAccount:gmail-api-push@system.gserviceaccount.com for your topic as given here?

0

As discussed in Cloud Pub/Sub documentation, please try the following for 403 - Forbidden error:

  • 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 <projectId>@cloudservices.gserviceaccount.com and the Compute Engine Service account <projectId>-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 <project-id>@appspot.gserviceaccount.com.

In addition to that, you may want to also check push endpoints configuration as suggested in this related SO post.

Community
  • 1
  • 1
Teyam
  • 7,686
  • 3
  • 15
  • 22