As suggested, I'm opening an issue here to get some help!
I want to set up a 'Login with Patreon' button but I can't get patreon-js to work on a F(irebase)EAN stack. Problem is I'm very new to backend stuff on a node server and I don't really know what I'm doing...
When I click my login button, a popup appears to authorize (or not) me to access the user's data. On allow, it redirects the user to my localhost and returns the response code.
Object {code: "randomStringHere", state: "None"}
It also triggers this request on my server :
GET /features?code=randomStringHere&state=None 200 4.193 ms - -
Server-side (code extracted from the exemple):
// Imports & server stuff above
var CLIENT_ID = 'myId';
var CLIENT_SECRET = 'mySecret';
var redirect = 'http%3A%2F%2Flocalhost%3A9000%2Ffeatures';
var loginUrl = formatUrl({
protocol: 'https',
host: 'patreon.com',
pathname: '/oauth2/authorize',
query: {
response_type: 'code',
client_id: CLIENT_ID,
redirect_uri: redirect,
state: 'chill'
}
});
app.get('/', function (req, res) {
res.send('<a href="' + loginUrl + '">Login with Patreon</a>');
});
app.get('/oauth/redirect', function (req, res) {
var code = req.query.code;
var _oauth = oauth(CLIENT_ID, CLIENT_SECRET);
var getTokens = _oauth.getTokens;
getTokens(code, redirect, function (err, _ref) {
var access_token = _ref.access_token;
if (err) {
console.error(err);
return res.send(err.message);
}
var client = patreon(access_token);
client('/current_user', function (uerr, user) {
if (uerr) return console.error(uerr);
client('/current_user/campaigns', function (cerr, campaigns) {
if (cerr) return console.error(cerr);
res.send(oauthExampleTpl({ user: user, campaigns: campaigns }));
});
});
});
});
function oauthExampleTpl(_ref2) {
var user = _ref2.user;
var campaigns = _ref2.campaigns;
return '\n<!DOCTYPE html>\n<html>\n <head>\n <meta charset="utf-8">\n <title>Oath Results</title>\n <style>\n .container {\n max-width: 800px;\n margin: auto;\n }\n .jsonsample {\n max-height: 500px;\n overflow: auto;\n margin-bottom: 60px;\n border-bottom: 1px solid #ccc;\n }\n </style>\n <style>' + jsonStyles + '</style>\n </head>\n <body>\n <div class="container">\n <h1>Oauth Example</h1>\n <h2>/current_user</h2>\n <div class="jsonsample">' + jsonMarkup(user) + '</div>\n <h2>/current_user/campaigns</h2>\n <div class="jsonsample">' + jsonMarkup(campaigns) + '</div>\n </div>\n </body>\n</html>';
}
As I said, I'm very new to this, so how can you help me?
Hi!
As suggested, I'm opening an issue here to get some help!
I want to set up a 'Login with Patreon' button but I can't get patreon-js to work on a F(irebase)EAN stack. Problem is I'm very new to backend stuff on a node server and I don't really know what I'm doing...
I'm using https://github.com/sahat/satellizer/ to manage this Auth.
Here's how I configured my provider :
When I click my login button, a popup appears to authorize (or not) me to access the user's data. On allow, it redirects the user to my localhost and returns the response code.
It also triggers this request on my server :
Server-side (code extracted from the exemple):
As I said, I'm very new to this, so how can you help me?
Thanks in advance!