I have been struggling to get from a post request a token, to authenticate a plugin on the client-side. I managed it to work by calling the authentication on the client-side but this is not secure so I am trying to make it work on the server-side.
On the client-side, I wrote
Template.stripoCreateEmail.onCreated(function () {
Meteor.call('stripoPlugin', (error, token) => {
console.log(token);
loadDemoTemplate(initPlugin, token);
});
});
and on the server
Method.create('stripoPlugin', function () {
request.post('https://plugins.stripo.email/api/v1/auth', {
json: {
pluginId: 'Plugin_Key',
secretKey: 'Secrate_Key'
}
}, (error, res, body) => {
if (error) {
console.error(error)
return
}
console.log(`statusCode: ${res.statusCode}`);
console.log('token: ' + body.token);
token = body.token; // How can I get that token to the client side?
});
});