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

Example needed #16

Open
marcoschwartz opened this issue Jun 1, 2015 · 5 comments
Open

Example needed #16

marcoschwartz opened this issue Jun 1, 2015 · 5 comments

Comments

@marcoschwartz
Copy link

Hello,

Really nice module, I am trying to use it but I don't know what to put in options. I have a logged Google user on my app this part is working. I am trying:

GoogleApi.get('/analytics/v3', options, function(answer) {
   console.log(answer);
 });

In the console I get: message: "Auth token not found.Connect your google account [403]"

Any help would be appreciated. Thanks!

@tmeasday
Copy link
Member

tmeasday commented Jun 2, 2015

Hi @marcoschwartz does this help: https://github.com/percolatestudio/meteor-google-api/blob/master/README.md#tokens

Sounds like we need some better error messages but this should hopefully get you through.

@xinranxiao
Copy link

If you removed the autopublish package, you will need to publish your accessToken in order for this library to fetch your token.

Meteor.publish(null, function() {
  return Meteor.users.find(this.userId, { fields: { 
    'services.google.accessToken': 1, 
    'services.google.expiresAt': 1 
  }});
});

With autopublish enabled, accounts-google automatically adds the accessToken and expiresAt fields to the list of fields to be autopublished. Refer to the source code here https://github.com/meteor/meteor/blob/devel/packages/accounts-google/google.js#L15 and here https://github.com/meteor/meteor/blob/d8944f1b4d5a393a1292359d9a6ff09f147e53a4/packages/accounts-base/accounts_server.js#L24 for reference.

I left out refreshToken but you can add it if you want to (careful on the client)

@marcoschwartz
Copy link
Author

Thanks! I managed to make it work with that. I know have the issue that many requests are executed at the same time to Google, which fails because there is a rate limit. Is there something included in the library to limit the number of calls/second? Or can you recommend something? Thanks.

@tmeasday
Copy link
Member

tmeasday commented Jun 3, 2015

Hmm, not at this stage now. I think a generic rate limiting library would make sense, no need to work it into this one I wouldn't have thought.

@donl
Copy link

donl commented Sep 3, 2015

It appears the above example should be in the form of:

GoogleApi.get('/analytics/v3', options, function(error, answer) {
console.log(answer);
});

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