Authentication
The MoneyMonk API uses OAuth 2 with the authorization code flow and PKCE (S256). Every call to a resource endpoint must be made using an access token obtained through this flow.
We do not support the implicit flow, the resource owner password credentials flow, or the client credentials flow.
Registering a client
We provide client registration on a case-by-case basis for selected partners and integrations. See Requesting access for how to apply.
Clients are configured with:
- A client ID — a public identifier for your application.
- An optional client secret — a confidential value used to authenticate your application at the token endpoint. Treat this as a password and never embed it in code that is distributed to end users (e.g. mobile or single-page apps). A client secret is mandatory for applications that have a dedicated backend. Applications that do not have a dedicated backend should not use a client secret, since they run on user devices and cannot securely store a secret.
- A redirect URI — exact URL we will redirect the user to after they grant or deny consent. Redirect URIs are matched exactly, including scheme, host, port, and path. Only a single redirect URI can be used.
Discovery
A machine-readable description of the authorization server is available at:
Code
This document follows RFC 8414 and lists the authorization endpoint, the token endpoint, the supported scopes, the supported grant types and response types, the supported PKCE methods, and the supported client authentication methods at the token endpoint.
The authorization code flow
1. Generate a PKCE code verifier, code challenge, and state
Generate a high-entropy random string of 43–128 characters (the code verifier) and store it in your application's session. Derive the code challenge by SHA-256 hashing the verifier and base64url-encoding the result without padding.
PKCE is mandatory for all clients, including confidential ones, and only the S256 method is supported.
To generate a code verifier and code challenge in Python, you can refer to the following example code. A code verifier is a cryptographically secure 48-byte random value that is Base64URL-encoded, resulting in an encoded length of 64 characters.
Code
It is also recommended to generate a cryptographically secure random value for the state, which can be done in a similar way. To generate a Base64URL-encoded value from 32 bytes:
Code
2. Redirect the user to the authorization endpoint
Send the user's browser to:
Code
Parameters:
| Parameter | Required | Description |
|---|---|---|
client_id | yes | Your registered client ID. |
response_type | yes | Must be code. |
code_challenge_method | yes | Must be S256. |
code_challenge | yes | PKCE challenge derived from the verifier. |
state | recommended | Opaque value you use to maintain state between request and callback, and to defend against CSRF. We will return it unchanged on the redirect. |
scope | no | Space-separated list of scopes you are requesting (see Scopes). If omitted, the full set of scopes registered for the client is requested. |
redirect_uri | no | The redirect URI registered for your client. If provided, you must also send the same redirect URI to the token endpoint. There is no need to use this parameter, since we only support one redirect URI per client, but it is supported to be compliant with the OAuth 2.0 standard. |
MoneyMonk shows the user a consent screen where they select the administration to grant access to and see which scopes are being requested. Consent covers a single administration, and the resulting tokens are valid for that administration only. Only the primary user of an administration can grant consent; other users with access to the administration cannot authorize an integration. After the user grants consent, we redirect them back to your redirect_uri with a code and the state you supplied:
Code
If the user denies consent or an error occurs, we redirect to your redirect_uri with error and error_description parameters as defined in RFC 6749 section 4.1.2.1.
Authorization codes are single-use and expire after two minutes.
3. Exchange the code for tokens
From your server, POST to the token endpoint with an application/x-www-form-urlencoded body:
Code
Confidential clients need to provide their client credentials by either
- Adding a
client_secretparameter in the body (with their client secret as value) - Using HTTP Basic Auth: The client_id and client_secret are encoded using application/x-www-form-urlencoded rules. They are then concatenated as
<client_id>:<client_secret>, base64-encoded. The resulting value is sent in theAuthorizationheader asAuthorization: Basic <base64-encoded-value>.
A successful response is of the form:
Code
- The access token is valid for 4 hours (
expires_in, in seconds). - The refresh token is valid for 60 days (
refresh_token_expires_in, in seconds). - The
scopefield lists the scopes that were granted. These are always the scopes that were requested.
When the last refresh token expires, there is no way to get an access token, and the entire flow needs to be restarted, which requires user interaction to grant permission to the application.
Refreshing an access token
When an access token is close to expiring (or has expired), use the refresh token to obtain a new pair:
Code
For public clients, the client_secret should be omitted from the request.
The response has the same shape as the authorization code response. Refresh tokens are rotated on each use; the previous refresh token becomes invalid as soon as the new one is issued. Store the new refresh token immediately.
Revoking a token
To proactively invalidate an access or refresh token (for example because the user has logged out, or disconnected your integration), call the revocation endpoint:
Code
For public clients, the client_secret should be omitted from the request.