Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gmail API: users.watch - topicName required. #976

Closed
felicienb opened this issue Jan 30, 2018 · 3 comments
Closed

Gmail API: users.watch - topicName required. #976

felicienb opened this issue Jan 30, 2018 · 3 comments
Assignees

Comments

@felicienb
Copy link

felicienb commented Jan 30, 2018

I don't understand why the call of gmail.users.watch answers me that topicName is required:

CODE

  var gmail = google.gmail("v1");
  gmail.users.watch({
    auth: auth,
    userId: "me",
    resource: {
      topicName: projects/{myproject}/topics/{mytopic},
    }
  }, function(err, response) {
    if (err) {
      errorPrinter('setWatch', err);
      return;
    }
    printer(response);
   });
  }

RESPONSE

Error on request: setWatch, Error: { Error: topicName required
    at new RequestError (/Users/felicien/Artefact/Estee-Lauder/Node/node_modules/google-auth-library/lib/transporters.js:34:42)
    at Request._callback (/Users/felicien/Artefact/Estee-Lauder/Node/node_modules/google-auth-library/lib/transporters.js:96:27)
    at Request.self.callback (/Users/felicien/Artefact/Estee-Lauder/Node/node_modules/request/request.js:186:22)
    at emitTwo (events.js:126:13)
    at Request.emit (events.js:214:7)
    at Request.<anonymous> (/Users/felicien/Artefact/Estee-Lauder/Node/node_modules/request/request.js:1163:10)
    at emitOne (events.js:116:13)
    at Request.emit (events.js:211:7)
    at IncomingMessage.<anonymous> (/Users/felicien/Artefact/Estee-Lauder/Node/node_modules/request/request.js:1085:12)
    at Object.onceWrapper (events.js:313:30)
  code: 400,
  errors: 
   [ { domain: 'global',
       reason: 'invalidArgument',
       message: 'topicName required' } ] }

And I had the same problem with gmail.user.history.list but I could bypass it by overcharging the url because it is a GET request, so I could give the parameters in the url query.

I also tried to use the HTTP request, but it seems that I don't use the good access_token, whereas I am using the one creating by the API and it works perfectly on user.getProfile.

CODE

function setWatch(auth) {
  request({
  url: "https://content.googleapis.com/gmail/v1/users/me/watch?access_token=" + auth.credentials.access_token,
  method: "POST",
  data: {
    topicName: config.topicInput,
  },
  json: true
}, function(err, response) {
  if(err) {
    errorPrinter("watch", err);
  } else {
  printer(response);
  }
});

RESPONSE

  body: 
   { error: 
      { errors: 
         [ { domain: 'global',
             reason: 'authError',
             message: 'Invalid Credentials',
             locationType: 'header',
             location: 'Authorization' } ],
        code: 401,
        message: 'Invalid Credentials' } } }

Any help ?

Félicien

@felicienb felicienb changed the title User:watch - topicName required. Gmail API: users.watch - topicName required. Jan 30, 2018
@juggernaut451
Copy link

experiencing same issue

@workmaster2n
Copy link

Downgrading to version 24 works for now. See the linked comment on the PR to see the line of code that breaks this.

@JustinBeckwith
Copy link
Contributor

Greetings! I was able to get this working with the latest version (v27). You can see a full working example in #1073.

Usually when folks have these kinds of issues, it's because there's a non-compatible version of google-auth-library installed. Can you please remove google-auth-library from your package.json, run npm install, and verify you're still having issues?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants