Skip to content

Instantly share code, notes, and snippets.

@graphicbeacon
Last active March 11, 2018 17:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save graphicbeacon/ee69c811ca8644c1c3c2fd9e439c0c6b to your computer and use it in GitHub Desktop.
Save graphicbeacon/ee69c811ca8644c1c3c2fd9e439c0c6b to your computer and use it in GitHub Desktop.
How to create an application using the Monzo Bank API
app.get('/oauth/callback', (req, res) => {
const { client_id, client_secret, redirect_uri } = oauthDetails;
const { code } = req.query;
const monzoAuthUrl = `https://api.monzo.com/oauth2/token`;
// Initiate request to retrieve access token
request.post({
url: monzoAuthUrl,
form: {
grant_type: 'authorization_code',
client_id,
client_secret,
redirect_uri,
code
}
}, (err, response, body) => {
accessToken = JSON.parse(body); // Populate accessToken variable with token response
res.redirect('/accounts'); // Send user to their accounts
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment