OAuth flow for a command line app - redirect_uri?


I’m trying to build a super-simple command line app which will interrogate my business account and produce a CSV statement which matches the format required by my accountant, which the current CSV export provided by Monzo doesn’t.

As a command line app, I don’t have a web server, so providing the redirect_uri in the first step of the OAuth flow is tricky - is there any sensible workaround for that? I tried providing a file:/// link, in the hopes that the redirect would just get dumbly sent back to my browser, but it seems to validate the link, and I’m getting a 400 back with redirect_uri is invalid in the response body.

I could obviously create this to run on a web server, and therefore easily have the redirect_uri, but it seems like overkill to have a web server running for such a trivial application.

Can’t you just use http://localhost or https://www.monzo.com if it insists on HTTPS?

All you really need is a bit of info from the query string in the url it redirects you to to. So set your redirection to https://localhost, open browser and it’s dev tools. Go through the authentication dance and let the browser fail to connect to localhost. Look through the requests in dev tools to find that failed one, find the query string and grab what you need.

Apologies if ot looks like I’m being deliberately vague, I just don’t recall which of the parameters in the query string it is that you’re after.

1 Like

As others have said, you’d need a URL as that’s the craic for an authorisation grant. Get a server setup on localhost if you don’t have one. You don’t need SSL and regardless of that, you wouldn’t be able to use https://monzo.com.

Thanks for the above - I ended up making a locally-hosted web app, which does the OAuth dance on startup, then on clicking the button in the email takes me to a page listing my accounts, to choose which account I want the CSV from. A bit clumsier than I was planning on, but still perfectly good.

1 Like