I am using Node.js and the googleapis package. Along with passport for authentication.
When I run this code on my Node.JS app:
function start(user, oauth2){
// Start watching for new emails
gmail.users.watch({
auth: oauth2,
userId: 'me',
resource: {
topicName: 'projects/outrigger-170662/topics/gmail',
labelIds: ["Inbox"]
} `
}, function(err){
if (err){
console.log(err);
}
}); }
Note: I am actually passing in the user object and oauth2client, so that is not the issue.
I get this error:
data: { error: [Object] } },
code: 400,
errors:
[ { domain: 'global',
reason: 'invalidArgument',
message: 'Invalid topicName does not match projects/outrigger-170622/topics/*' } ] }
I am using the following scopes:
'email',
'profile',
'https://www.googleapis.com/auth/calendar',
'https://mail.google.com/',
'https://www.googleapis.com/auth/contacts'
I have created the gmail topic on my google cloud console and set allUsers
as a publisher. Is there something I am missing?
The site is live at https://outrigger.herokuapp.com/
Based on the error message, your actual project ID is outrigger-170622
, however in your request you are sending outrigger-170662
. It looks like this error is caused by a typo of 662 vs 622. Try fixing this and see if the error goes away.