Open philcruz opened 9 years ago
Hmm.
So the idea would be to be able to pass in a refreshToken
and an updateAccessToken
function and have the default implementation be user.services.google.refreshToken
and something like Meteor.users.update(user._id, {$set: {'services.google.accessToken': X}})
?
Is everything happening server-side here for you also? (i.e. we don't publish the refreshToken
, call a method to update it).
@zol: what are your thoughts about accepting a PR for this? It adds complexity to the package but it seems a legit use case...
To clarify, the way I have it working is if you pass in options.user then it works as you have it. Alternatively, if you pass in options.refreshTokenParams like in my example so you can manually manage the tokens. This way it should be backwards compatible.
@tmeasday @philcruz - I can see how this would be useful. On the other hand, it's also kind of an edge case given that most do use Meteor accounts. Given that we haven't received requests for this, I would suggest forking the package for now and using it as a submodule in your project. If we receive more requests for the functionality, we'll extend the package.
I have a very similar requirement. @philcruz did you eventually publish any code, are you using meteor package oauth flow to get the initial tokens? i am looking for something to create the initial request + something to auto refresh
@ganySA I haven't published my fork yet but I will. I can't do it this week because I'm on travel. I'll do it the following week.
@ganySA You can check out my code at https://github.com/philcruz/meteor-google-api/tree/develop
Hi everybody,
I'm using @philcruz package, and I found it very useful to access Google's API (contacts in my case), as the single source of Meteor accounts I have for my users isn't Google.
So I vote for adding this extension if this is something you guys would consider.
@tmeasday @zol - I develop a dashboard app, where multiple oAuth tokens to multiple services are saved to dashboards, and not to Meteor accounts (since there might be multiple users using the same dashboard). So I assume this is a somewhat generic requirement other people might have and I would really like to see this implemented.
So I'm working with the Google APIs in a project and came across this package. It's nice that if the call fails it refreshes the token and retries the call for you. However, it's dependent on having a logged in user. You pass options.user and under the hood it fetches/updates from user and user.services.google.
In my project I'm handling OAuth manually so I don't have a logged in user. I would still like to have the refresh-retry functionality though. So I made some modifications that do that. Instead of passing in options.user you would pass options.refreshTokenParams
updateAccessToken = function(access_token) { console.log("in updateAccessToken"); Tokens.upsert( {account: Meteor.settings.account}, { $set: {
accessToken: access_token //expiresIn: result.data.expires_in } }
); }
Seem like a good approach?