Monzo Oauth2 refresh token with tasker app?

So basically im trying to relyably get my monzo balance with tasker which I can successfully do using HTTPGET to get the balance. However to get this to work im having to get tasker to open the monzo api playground webpage and copy the accesstoken from there to then use further down my tasks. This of course expires after a while and so if the HTTP Get request fails it will get as new code again.

I don’t like how this is being achieved as it has to actually unlock my device to do this (obviously not great for security)

So I am trying to get a new fresh token through tasker to replace the sloppy way I’m doing it now.
I can receive a refresh token through HTTPie as stated in the Api Docs but I just can’t get it to work within tasker for some reason.

Here’s the info I send to HTTPie

*http --form POST “https://api.monzo.com/oauth2/token” *
*“grant_type=authorization_code” *
*“client_id=SOMECODE” *
*“client_secret=SOMESECRET” *
*“redirect_uri=SOMEURL” *
“code=SOMECODE”

I’ve been at this for week’s now someone please put me out of my misery! :smile:

Here’s a reddit post I made that might have some more info if needed.

:wave: Heyo!

I think trying to do this directly from your phone is gonna be tough :thinking: If I’m reading right, you want to have your phone authenticate with our API so you can pull your balance.

Once you’ve authenticated (which I think you’ve done?) you need to use the grant_type of refresh_token as documented here.

That said, though, I think using your phone as the “server” will be rather challenging, as you’ll have to do it all through Tasker. If it was me, I’d get a cheapo Raspberry Pi Zero W for £10, have that be your server that handles all your auth, and exposes a JSON endpoint over your local network. Then your phone can call your Pi server, rather than interacting with the API directly.

Not sure if that helps or not, but just some ideas :grin: Good luck with it - and welcome to the forum! :hot_coral_heart:

1 Like

Hi and thanks for the reply,

I think it can be done through my phone it’s literally just getting the info I can send through httpie to be sent through taskers http request instead. I can save any info I receive into variables and once I get a refresh token into a variable everything will work, pull balance>access token expired error>run task that recieves new refresh token>use new token to pull balance again without error.

Here’s the options I have within tasker.

1 Like

Ah, gotcha! Sounds like this isn’t really specific to the Monzo API then, more just trying to get a specific request body out of Tasker.

I’d recommend pointing your HTTPie client and Tasker both at something like Requestbin and comparing the two requests :slight_smile:

1 Like