Open jiku opened 9 years ago
Hi @jiku - The package assumes you are running in a method call (so it knows which user's credentials to use when talking to google).
Can you try GoogleApi.get(..., {user: Meteor.users.findOne(this.userId)})
or the like? Does that fix the problem for you?
I don't think there's any way that from inside a library we can detect that we are running in the context of a publish function, so we'll need you to pass the user in no matter what. We should document this better I think.
Thanks, that fixed it. =)
I've added if (options.user) delete options.user;
before the API call in google-api-sync.js
, but maybe that's something Meteor strips off before the call is made?
I'm not sure what you mean @jiku ?
Sorry, should've added some context
...
if (options.user) delete options.user; // Avoid sending user? Or will Meteor discard extra HTTP.call options being passed to the API?
HTTP.call(method, this._host + '/' + path, options, function(error, result) {
...
I'm not that proficient with Meteor/Node yet, so it's a bit unclear to me if this became an issue with https://github.com/meteor/meteor/issues/1703
Good pickup @jiku. It probably doesn't do anything as request and HTTP don't have a user option AFAIK, but we shouldn't pass it through. #11
Cool. :) I made a PR if that's useable.
Is this issue supposed to be closed @jiku? I'm getting the [Error: Meteor.userId can only be invoked in method calls. Use this.userId in publish functions.] error in my publish-functions, and when I try to implement your code I get a 500 error regarding refreshtokens.
With
I get
When using GoogleApi in a package. Any ideas? Tried with a clean 1.0.5 app and package X. Only dependencies in package X are what's needed to log in to Google, which it does just fine. Tests run fine too. I'm using the same credentials successfully in other apps, so I'm pretty sure it's not a permissions, scope, etc, problem.