Code that produces the bottom query:
const userparams = {
external_id: user._id.toString(),
email: user.email,
username: user.username.replace(/\s/g, ''),
};
const payload = new Buffer(querystring.stringify(userparams), 'utf8').toString('base64');
const hmac = crypto.createHmac('sha256', DiscourseSSOKey);
hmac.update(payload);
const query = querystring.stringify({
sso: payload,
sig: hmac.digest('hex'),
api_username: UserName,
api_key: API Key,
});
console.log(query);
fetch('https://community.somesite.com/admin/users/sync_sso', {
method: 'POST',
body: query,
})
.then(res => res.json())
.then(json => console.log(json));
Here’s the query that gets generated and passed as the body on the POST route:
sso=somelongSSOgenerated.&sig=somelongsignature&api_username=someusername&api_key=someAPIKey
This all still gives me a Route Not Found error in the rails logs.