I’m trying to get a refresh token using the Monzo API and Postman but when trying to authenticate I get the ‘Monzo Security’ window pop up, and then after clicking ‘continue to login’, entering my email address and completing the email step, I just get taken to a blank Postman callback page.
I’m guessing here but i’m not sure whether the OAuth2 functionality provided by Postman (not really used it before) expects for the auth url to perform the navigation within the same window (i.e. within the popup window it expects it to do the navigation to the callback url). Obviously with Monzo you’ll get an e-mail that has the url in instead which is outside the context of that popup window.
Normally if you get a 400 without any error in the response then it’s just a malformed request that is missing something. Normally people forgetting to set the correct grant_type or add the refresh_token key/value.
What does your request look like? It should be (using httpie):
Either your client secret is invalid or you have a mismatch of credentials.
So firstly, check your client secret is valid.
Secondly, do you have multiple clients setup on the developer portal? If so, it may be that you’re using a valid client_id and client_secret however, they are not the same ones that were used from where the refresh_token was generated (when you exchanged your auth code for the access token).
I mainly use Insomnia at the moment, but I think Postman is similar.
It’s a two step process:
Acquire the auth key
This step you seem to do already. Once you have the link in the email, copy out the value after “key=”. But without the optional “state=+”.
Use environment variable in POST request for access token
In Postman you can use Environments. Set one up for Monzo and add a variable (e.g. auth_code) and copy over the code from step 1.
Now you can reference this variable as {{auth_code}} and use in your POST request for the access_token.
If it helps, I have a Monzo Workspace set up in Insomnia. Could share, if you would like to see an example.
Thinking of this, it’s probably a little overkill with the environment variable. You could just copy the code into the value of the body key “code”. But guess I still have the hope, that I could find a way of automating this in Insomnia / Postman.