Skip to content

Instantly share code, notes, and snippets.

@anabellaspinelli
Last active October 13, 2018 08:03
Show Gist options
  • Save anabellaspinelli/17c088103b40f21ddca4f0633ee0d80e to your computer and use it in GitHub Desktop.
Save anabellaspinelli/17c088103b40f21ddca4f0633ee0d80e to your computer and use it in GitHub Desktop.
Plain Express OAuth client
const express = require("express");
const bodyParser = require("body-parser");
const request = require("superagent");
const app = express();
app.use(bodyParser.json());
app.get("/callback", (req, res, next) => {
return request
.post("https://api.typeform.com/oauth/token")
.type("form")
.send({
code: req.query.code,
client_id: "xxx",
client_secret: "yyy",
redirect_uri: "http://localhost:9001"
})
.then(r => {
return res.send(`
Your token is ${r.body.access_token}!!
`);
})
.catch(err => {
console.error(err);
});
});
app.listen(9001, () => {
console.log('Server running on http://localhost:9001' );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment