Last active
October 13, 2018 08:03
-
-
Save anabellaspinelli/17c088103b40f21ddca4f0633ee0d80e to your computer and use it in GitHub Desktop.
Plain Express OAuth client
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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