How To – Node-Red Monzo
This post will show you how to use the node-red node I developed (node-red-contrib-monzo) to help make an API connection to Monzo easier.
There are two requirements for this to work
- You must have a Monzo account
- You must have node-red running that you can access.
Once both requirements have been met, you are ready to start.
You must begin by heading to your node-red window, for example mine is http://localhost:1880. Once there you need to head to the palette manager and click on the install tab. then search for “Monzo” the package will be called “node-red-contrib-monzo”, see image below.
Additionally you can install through npm
npm install node-red-contrib-monzo
Creating an API OAuth Client
Once at this stage you will need to create a API client with Monzo. To create a client, head to https://developers.monzo.com, then log in with your Monzo account, it will typically send you a login email.
Once logged in, click “clients” on the top right and then click “New OAuth Client”. Name it as you wish.
This next part is crucial. If you want to have permanent authorisation (ie, always be able to make requests), Confidential must be set to TRUE. The next crucial part is setting the redirect url correctly, if this is not done right, you will not be able to get an access token.
The redirect url is unique to your node red installation however it will need to follow this scheme.
for example http://localhost:1880/monzo-creds
*Do not worry if you have a custom installation and have a different port, this is dynamically figured out by the node. (even if the port is web default 80, showing no port)*
Click submit, then click into the newly created client and take note of the clientID and the Secret.
(Please note if your client does not immediately appear, refresh the page)
Setting up the node
Once you have successfully installed the node and you have created a API OAuth Client you will find a new section of nodes called “banking” drag the Monzo node onto the flow. Now enter its configuration, you will first need to set up a credential.
To set up a new credential make sure the drop down is set to “add new monzo-credentials” then click the pencil button.
Add your newly generated ClientID and Secret into the node and click (Authorise Monzo), This will create a popup window, (be sure it is not blocked)
Go through the authentication process, once you have submitted, you will receive an email into your Monzo account email address with a link. Click the link and you will be taken to a page which should display the following.
If this is shown, you can close that tab/window and head back to your node-red tab/window, you will now see the following text “Successfully retrived access token and refresh token” in green, along with a filled in access token.
Click Add/Update, You now have a authorised node and can start making requests to the Monzo bank API.
Please note, the Refresh Token is not shown to the user, however is stored within the nodes credentials.
Using the node
Next select the kind of request you want to make from the request dropdown. Click Done and deploy your flow.
Anything you now inject into the node will initialise the API request you selected, test with an inject node on the input and a debug node on the output.
And you are good to go!