1

I am working on sending notification from gmail to webserver through pub/sub,

I have gone through documentation in that they have mentioned to enable the scopes

https://cloud.google.com/pubsub/configure

I am specifying the following scopes through code

https://www.googleapis.com/auth/cloud-platform,
https://www.googleapis.com/auth/pubsub

Even though after specifying these scopes after calling watch() for the particular user its giving me

Google::Apis::ClientError: forbidden: Error sending test message to Cloud PubSub projects/project-id/topics/topic-name : User not authorized to perform this action.

So do I need to enable these scopes from google console ? If yes then can you please tell us the directions for doing it.

  • check this link [How to use Pub/Sub with Ruby](https://cloud.google.com/ruby/getting-started/using-pub-sub) – Gagan Gami Feb 19 '16 at 11:05
  • @GaganGami thanks for the link however it doesn't mention anything related to scope, which I am looking for. – Rahul Feb 19 '16 at 12:33

1 Answers1

3

Scope is not relevant here. Gmail system always uses this service account "gmail-api-push@system.gserviceaccount.com". What you need to do is to give this service account a permission for publishing messages on your topic.

See also: https://developers.google.com/gmail/api/guides/push#grant_publish_rights_on_your_topic

Takashi Matsuo
  • 3,406
  • 16
  • 25