Help with OAuth for use in personal scripts

Hello everyone,

I like to use basic scripting to automate web services. I am a beginner at this, however I have been able to use ‘curl’ commands with web services such as Toggl and Airtable which are really useful.

I would like to write a script which downloads my latest transactions from Monzo once a day. I can do this when I log in via the playgrounds, I get a JSON result with all transactions – that is great. My issue is that the token then expires so I cannot use it in a daily script as I do with other web services.

I have tried setting up a client and getting a permanent token, but the api assumes that you are developing a web app, which I’m not, and it goes over my head.

So my question is, is it possible for me to query Monzo in a personal capacity, without having to write a web app (which I cannot do). If anyone can help, I would really appreciate it.

FWIW I use Keyboard Maestro for my scripts, and use ‘Shell script’ actions to query web apps for JSON data.

Many thanks,

Andy

You need to obtain a refresh token as if you were developing an actual web app, and use that token to obtain short-lives access tokens when they expire.

Do you know if there is a way to obtain a refresh token using a shell script on macOS? I have looked at the documentation, but I don’t know how to create a ‘redirect uri’. Is it possible to create a one off uri which works locally so that I can receive the refresh token?

Thanks,

Andy

Yes there is a way. If you read up on how oAuth works you should be able to figure it out. Alternatively, download Paw (a graphical HTTP client, 30-day free trial) and do the oAuth flow in there. Once you obtain the refresh token manually you can just hardcode it in your application as it’s not supposed to expire.

The redirect URI is there so that in a conventional web app scenario the token is passed back to your app. If you’re doing the process manually, you don’t need to actually run a server at that URL. You can set the redirect URL to a non-existent one and just grab the token you need from the URL manually.

2 Likes

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.