Meteor and Patreon API

#1

Hello,

How can I make use of the Patreon API from my meteor app?
Can you please guide on how to do this?

Thanks

#2

You can use the Patreon API from meteor with the patreon package on npm.

The documentation for using the Patreon API is here:
https://docs.patreon.com/?javascript

Without a more specific question on what you are trying to do, what you have tried so far, and what issue you are encountering, I can’t help any further than pointing to the official resources

#3

Thanks for the reply.
I have a link labeled “Link your Patreon account” that goes to an url like this:

www.patreon.com/oauth2/authorize
    ?response_type=code
    &client_id=<your_client_id>
    &redirect_uri=<your_redirect_uri>

I am using Flow router that doesn’t support server routes.

How do I read the code query param when Patreon redirects back to my Meteor app?

https://mymeteorapp.com/custom-uri
    ?code=<single_use_code>
    &state=<string>

Then I have to call an http api via POST method,
How is this done with Meteor? axios? fetch?

Thanks for your reply, you’ve saved me a couple of time in the past.

#4

@jpfernandezl

Would the webapp package be useful for this? It will run from the server and accept the incoming request before it passes it on.

See the example url:

// Listen to incoming HTTP requests (can only be used on the server).
WebApp.connectHandlers.use('/hello', (req, res, next) => {
  res.writeHead(200);
  res.end(`Hello world from: ${Meteor.release}`);
});

Then your url could be something like (instead of /hello it’d be something like /patreon-callback-uri or whatever you tell Patreon what your calback uri is )

https://mymeteorapp.com/patreon-callback-uri
    ?code=<single_use_code>
    &state=<string>

Then you’d read the query params from the req object.

I think that should work.
:slight_smile:

1 Like
#5

Thanks for your reply.
After reading the query param the req object and saving it to the user collection
I would have to do a redirect to a route define with Flow router?
How do I exec a POST call with the code query param from there?

#6

You’d do a HTTP.call(‘post’, with your post payload) or HTTP.post (with your post payload) within the connectHandler, and do a res.end() to tell Patreon you’ve received the info, then call next() - that should send the request onto the client, which your route can then pick up.

I think (hope!) that’s the way it works - give it a whirl!

edit: I’m going to look like a damn fool if it doesn’t. :wink: