@lunch-money/developer-docs 2.11.2-preview.9 → 2.11.3-preview.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,6 +20,10 @@ history entries.
20
20
  legal company name is required.
21
21
  - Use “Developer Portal,” “Developers page,” and “API reference” consistently.
22
22
  Preserve different capitalization only for an exact UI label.
23
+ - Use “budget account” for the Lunch Money data container that holds a budget,
24
+ transactions, categories, and financial accounts. Use “account” only when the
25
+ context is unambiguous, and preserve exact UI labels such as “Create a New
26
+ Budget Account.”
23
27
  - Write “v1” and “v2” in prose. Use “V2 API” only where it is an established
24
28
  proper label, such as the rendered reference title.
25
29
  - Distinguish authentication from authorization, personal access tokens from
@@ -5,12 +5,12 @@ Welcome to the Lunch Money developer API! This API has enabled the Lunch Money u
5
5
  Most users interact with their Lunch Money data using the official web or mobile app. Making API calls is another way to interact with your Lunch Money data. You can make API calls that **get** your data for you, allowing you to do other things with it, like generating your own charts or simply archiving your data. You can also make API calls that **change** or **delete** your data. Any changes you make are permanent, just like they would be if you made changes using the web or mobile app.
6
6
 
7
7
  > [!WARNING]
8
- > Changes made via the API are permanent and cannot be undone. Always use a test budget when getting started.
8
+ > Changes made via the API are permanent and cannot be undone. Always use a test budget account when getting started.
9
9
 
10
10
 
11
- ## Create a test budgeting account
11
+ ## Create a test budget account
12
12
 
13
- Since changes to your data made by the API are permanent, the best way to begin interacting with the API is to <a href="https://support.lunchmoney.app/miscellaneous/unlimited-budgeting-accounts" target="_blank" rel="noopener noreferrer">create a new test budgeting account</a> in your existing Lunch Money account. As you start using the API, you can interact with this test account and ensure that your real data is not modified.
13
+ Since changes to your data made by the API are permanent, the best way to begin interacting with the API is to <a href="https://support.lunchmoney.app/miscellaneous/unlimited-budgeting-accounts" target="_blank" rel="noopener noreferrer">create a new test budget account</a> in your existing Lunch Money account. As you start using the API, you can interact with this test budget account and ensure that your real data is not modified.
14
14
 
15
15
  :::tabs
16
16
 
@@ -18,26 +18,26 @@ Since changes to your data made by the API are permanent, the best way to begin
18
18
  Click on the green circle in the upper right hand corner in the Lunch Money Web App
19
19
  ![Green Budgets Icon](/images/green_budget.png)
20
20
 
21
- @tab 2. Create a New Budget
22
- Click on the "Create a New Budget Account" link and give your new budget a name like "API Test Budget"
21
+ @tab 2. Create a New Budget Account
22
+ Click on the "Create a New Budget Account" link and give your new budget account a name like "API Test Budget"
23
23
  ![Create New Budget](/images/new_budget.png)
24
24
 
25
25
  @tab 3. Add Test Data
26
- Choose the option to "Set up Demo". This will add categories, accounts, tags and several months worth of transactions to your new budget.
26
+ Choose the option to "Set up Demo". This will add categories, accounts, tags and several months worth of transactions to your new budget account.
27
27
  ![Add Demo Data](/images/DemoData.png)
28
28
  :::
29
29
 
30
30
  ## Getting a personal access token
31
31
 
32
- Lunch Money API requests are authenticated using the Bearer Token authentication method. In plain English, this means that you will pass a personal access token associated with your budgeting account to Lunch Money. This is so we know which account to operate on and that the request came from someone who can access that account.
32
+ Lunch Money API requests are authenticated using the Bearer Token authentication method. In plain English, this means that you will pass a personal access token associated with your budget account to Lunch Money. This is so we know which account to operate on and that the request came from someone who can access that account.
33
33
 
34
- This guide uses a personal access token so you can explore the API with your own budgeting account. If you are building an application that other people will connect to Lunch Money, start with the [OAuth overview](/oauth) instead.
34
+ This guide uses a personal access token so you can explore the API with your own budget account. If you are building an application that other people will connect to Lunch Money, start with the [OAuth overview](/oauth) instead.
35
35
 
36
36
  :::tabs
37
37
 
38
38
  @tab 1. Go to the Developers Page
39
39
 
40
- Navigate to <a href="https://my.lunchmoney.app/developers" target="_blank" rel="noopener noreferrer">the developers page in the Lunch Money web app</a>. Look at the green circle in the upper right hand corner and make sure that it is showing the test account that you just created. If you aren't sure which account is active, you can click on the green circle to bring up the "Switch Accounts" dialog. This will show you the full names of all the accounts associated with your account. Select the test budgeting account you created.
40
+ Navigate to <a href="https://my.lunchmoney.app/developers" target="_blank" rel="noopener noreferrer">the developers page in the Lunch Money web app</a>. Look at the green circle in the upper right hand corner and make sure that it is showing the test budget account that you just created. If you aren't sure which budget account is active, you can click on the green circle to bring up the "Switch Accounts" dialog. This will show you the full names of all your budget accounts. Select the test budget account you created.
41
41
  ![Green Budgets Icon](/images/green_budget.png)
42
42
 
43
43
  @tab 2. Request Access Token
@@ -48,7 +48,7 @@ In the upper right hand corner of the page, give your personal access token a la
48
48
  After you do this, the web page will show you a long alphanumeric string. This is your personal access token. Hit the copy button and save this token somewhere safe. It is only shown to you when you create it.
49
49
  :::
50
50
 
51
- Congratulations! You've got a personal access token and are ready to make an API request! Later, when you are more comfortable with the API, you can repeat this process to create a new personal access token associated with your real budget.
51
+ Congratulations! You've got a personal access token and are ready to make an API request! Later, when you are more comfortable with the API, you can repeat this process to create a new personal access token associated with your real budget account.
52
52
 
53
53
  > [!WARNING]
54
54
  > Treat your personal access tokens like passwords. Don't share them with anyone you don't trust.
@@ -83,7 +83,7 @@ Scroll down to the section called "Get Current User" and hit the "Test Request"
83
83
  ![TestRequest.png](/images/TestRequest.png)
84
84
  :::
85
85
 
86
- This will pop up a dialog box that you can use to send an API request. This is a simple endpoint, so just hit the "Send" button. You should see a response that includes your name and the name of your test budget.
86
+ This will pop up a dialog box that you can use to send an API request. This is a simple endpoint, so just hit the "Send" button. You should see a response that includes your name and the name of your test budget account.
87
87
 
88
88
  From here, you can explore the rest of the Lunch Money API and start thinking about what you might do with it.
89
89
 
@@ -10,13 +10,13 @@ The v2 API is available at:
10
10
  https://api.lunchmoney.dev/v2
11
11
  ```
12
12
 
13
- To explore the API or work with your own budgeting account, create a personal access token on the <a href="https://my.lunchmoney.app/developers" target="_blank" rel="noopener noreferrer">Developers page</a>. If you are building an application for other Lunch Money users, [use OAuth](/oauth) instead. Both kinds of access token are sent as a Bearer token with each request:
13
+ To explore the API or work with your own budget account, create a personal access token on the <a href="https://my.lunchmoney.app/developers" target="_blank" rel="noopener noreferrer">Developers page</a>. If you are building an application for other Lunch Money users, [use OAuth](/oauth) instead. Both kinds of access token are sent as a Bearer token with each request:
14
14
 
15
15
  ```http
16
16
  Authorization: Bearer YOUR_ACCESS_TOKEN
17
17
  ```
18
18
 
19
- See the [Getting started guide](/getting-started) for a full walkthrough, including how to create a test budget and make your first request.
19
+ See the [Getting started guide](/getting-started) for a full walkthrough, including how to create a test budget account and make your first request.
20
20
 
21
21
  ## Trying the API without real data
22
22
 
@@ -1,6 +1,6 @@
1
1
  # Implement the authorization-code flow
2
2
 
3
- After you [register an OAuth client](/oauth/register-client), your application uses its settings—including its client ID, client secret, if configured, and a registered redirect URI—to implement the authorization flow. As shown in the [OAuth overview](/oauth), your application sends the user to Lunch Money, Lunch Money returns an authorization code to your callback, and your application exchanges that code for tokens. Step 4 explains how to identify the Lunch Money user and budgeting account associated with the resulting connection.
3
+ After you [register an OAuth client](/oauth/register-client), your application uses its settings—including its client ID, client secret, if configured, and a registered redirect URI—to implement the authorization flow. As shown in the [OAuth overview](/oauth), your application sends the user to Lunch Money, Lunch Money returns an authorization code to your callback, and your application exchanges that code for tokens. Step 4 explains how to identify the Lunch Money user and budget account associated with the resulting connection.
4
4
 
5
5
  This guide walks through that process for a **Confidential web client**. Your server handles the callback and token exchange and keeps the client secret and refresh tokens secure. If you are building a standalone mobile or desktop application, read the [native application guidance](/oauth/native-apps) instead. Expo developers can also follow the [native Expo sample](/oauth/sample-applications#native-expo-sample).
6
6
 
@@ -17,6 +17,8 @@ For Node.js and TypeScript, [`openid-client`](https://github.com/panva/openid-cl
17
17
 
18
18
  The [confidential Node.js sample application](/oauth/sample-applications#understand-the-confidential-teaching-code) shows this library in a complete Lunch Money flow. Begin with its [`src/oauth` guide](https://github.com/lunch-money/lm-oauth-confidential-node-example/blob/main/src/oauth/README.md), then follow the listed reading order from protocol types and discovery through authorization, callback validation, credential storage, API access, optional refresh, and revocation.
19
19
 
20
+ Lunch Money requires PKCE with the `S256` challenge method for every authorization-code flow, including confidential clients that also authenticate with a client secret.
21
+
20
22
  ## Configure Lunch Money with discovery
21
23
 
22
24
  Your OAuth library needs to know where to send the user for authorization, where to exchange codes for tokens, and which protocol features Lunch Money supports. Instead of configuring each value separately, give the library the Lunch Money issuer:
@@ -42,18 +44,18 @@ On your server, generate:
42
44
 
43
45
  Redirect the browser to the discovered authorization endpoint with `response_type=code`, your `client_id`, exact `redirect_uri`, `state`, `code_challenge`, and `code_challenge_method=S256`.
44
46
 
45
- Lunch Money handles sign-in, budgeting-account selection, and consent. It may reuse an existing browser login session, and the person may be able to continue with a different Lunch Money user from the authorization screen. A user may have multiple budgeting accounts, but this authorization is for the one they select. Keep the authorization attempt bound to the authenticated application user who started it; do not assume which Lunch Money user will complete it.
47
+ Lunch Money handles sign-in, budget-account selection, and consent. It may reuse an existing browser login session, and the person may be able to continue with a different Lunch Money user from the authorization screen. A user may have multiple budget accounts, but this authorization is for the one they select. Keep the authorization attempt bound to the authenticated application user who started it; do not assume which Lunch Money user will complete it.
46
48
 
47
49
  > [!NOTE] Scopes come from the client registration
48
50
  > You do not need to send `scope`. If your OAuth library includes it, Lunch Money ignores the requested value and uses the client's complete registered scope set. An authorization request cannot narrow or expand that set; changing scopes requires a replacement client.
49
51
 
50
52
  ## 2. Handle the callback
51
53
 
52
- The callback receives either `code` and `state`, or an OAuth `error` and the original `state`. Before exchanging a code:
54
+ The callback receives either `code` and `state`, or an OAuth `error` and the original `state`. Lunch Money also returns `iss`, which identifies the authorization server that produced the response. Before exchanging a code:
53
55
 
54
56
  1. compare `state` with the one-time value stored in the initiating session;
55
57
  2. reject missing, mismatched, or reused state;
56
- 3. reject unexpected issuer or callback parameters;
58
+ 3. compare the decoded `iss` value with the `issuer` value from authorization-server metadata using exact string comparison, and reject a missing or mismatched value;
57
59
  4. consume the stored state and PKCE verifier once; and
58
60
  5. remove authorization parameters from the visible browser URL before rendering a page.
59
61
 
@@ -65,6 +67,18 @@ Send a form-encoded request to the discovered token endpoint with `grant_type=au
65
67
 
66
68
  Keep the returned credentials in temporary server-side state while you identify the authorization. Do not make an unidentified credential set available to the application or commit it to the normal connection store yet. If a `refresh_token` is returned, treat it as a high-value credential even during this temporary step.
67
69
 
70
+ The token endpoint returns a JSON object with these fields:
71
+
72
+ | Field | Type | When present |
73
+ | --- | --- | --- |
74
+ | `access_token` | string | Always. Treat it as an opaque credential. |
75
+ | `token_type` | string | Always. Lunch Money returns `Bearer`. |
76
+ | `expires_in` | integer | Always. Number of seconds until the access token is expected to expire. |
77
+ | `scope` | string | Always. Space-delimited scopes granted to the token. |
78
+ | `refresh_token` | string | When the registered client includes `offline_access`. |
79
+
80
+ Lunch Money does not return an `id_token`. A successful refresh response has the same shape and includes a replacement `refresh_token`; persist the complete replacement set together.
81
+
68
82
  ## 4. Identify and store the connection
69
83
 
70
84
  Send the access token in the header:
@@ -75,11 +89,11 @@ Host: api.lunchmoney.dev
75
89
  Authorization: Bearer YOUR_ACCESS_TOKEN
76
90
  ```
77
91
 
78
- The operation must be allowed by the token's scope and by the user's access to the selected budgeting account. See the [scope catalog](/oauth/scopes).
92
+ The operation must be allowed by the token's scope and by the user's access to the selected budget account. See [OAuth scopes](/oauth/scopes).
79
93
 
80
- Call `GET /v2/me` immediately after the token exchange, before normal credential persistence. It requires `me:read`. Strictly validate the response: `id` identifies the Lunch Money user, `account_id` identifies the selected budgeting account, and `budget_name` is its display name. When reconnecting, use this response to establish the account identity rather than assuming the user selected the same budget. See [users, budgeting accounts, and access tokens](/oauth/concepts#users-budgeting-accounts-and-access-tokens).
94
+ Call `GET /v2/me` immediately after the token exchange, before normal credential persistence. It requires `me:read`. Strictly validate the response: `id` identifies the Lunch Money user, `account_id` identifies the selected budget account, and `budget_name` is its display name. When reconnecting, use this response to establish the account identity rather than assuming the user selected the same budget account. See [users, budget accounts, and access tokens](/oauth/concepts#users-budget-accounts-and-access-tokens).
81
95
 
82
- Store the credential set under the authenticated application user's ID and the returned Lunch Money user `id` and `account_id`. Those three fields establish the owner and provider identity for the connection, even if your database also assigns an internal connection ID for routing. Atomically create a complete record when that combination is new, or replace the complete credential set when the same application user reauthorizes the same Lunch Money user and budgeting-account pair. Persist the access token, refresh token when present, scope, expiration metadata, Lunch Money user `id`, `account_id`, and `budget_name` together, then make that Lunch Money identity and connection active. Do not use `budget_name` as a key or try to derive identity by parsing the opaque access token.
96
+ Store the credential set under the authenticated application user's ID and the returned Lunch Money user `id` and `account_id`. Those three fields establish the owner and provider identity for the connection, even if your database also assigns an internal connection ID for routing. Atomically create a complete record when that combination is new, or replace the complete credential set when the same application user reauthorizes the same Lunch Money user and budget-account pair. Persist the access token, refresh token when present, scope, expiration metadata, Lunch Money user `id`, `account_id`, and `budget_name` together, then make that Lunch Money identity and connection active. Do not use `budget_name` as a key or try to derive identity by parsing the opaque access token.
83
97
 
84
98
  If `GET /v2/me` fails validation or the complete record cannot be persisted, discard the temporary credentials and leave existing connections unchanged. A successful token exchange alone must not create an unidentified or partially saved connection.
85
99
 
@@ -1,80 +1,93 @@
1
1
  # OAuth concepts
2
2
 
3
- These terms describe who participates in Lunch Money OAuth and what each credential can do.
3
+ OAuth connects your application to one Lunch Money user and one budget account at a time. This page explains who participates in that connection, what each credential does, and how to keep multiple connections separate. You do not need to know OAuth terminology before you start.
4
4
 
5
5
  ## Parties in the flow
6
6
 
7
- - **User (resource owner):** the Lunch Money user who authorizes a third-party application to make API requests on their behalf for one budgeting account.
7
+ - **User:** the Lunch Money user who authorizes a third-party application to make API requests on their behalf for one budget account. OAuth calls this person the *resource owner*.
8
8
  - **Application:** the complete product or service the developer builds. It may contain many features unrelated to Lunch Money; only its Lunch Money OAuth client is managed in the Developer Portal.
9
9
  - **Client:** the application's OAuth registration with Lunch Money: its `client_id`, type, redirect URIs, selected scopes, and—when applicable—client secret. The developer must register this client in the Developer Portal before the application can ask Lunch Money users to authorize API access.
10
10
  - **Authorization server:** the Lunch Money-owned service that presents the Lunch Money sign-in and consent screens, records the user's decision, and issues authorization codes and tokens. It also handles token requests, including exchanging authorization codes and refresh tokens for new tokens. The user signs in directly with Lunch Money; the third-party application never receives or sees their Lunch Money login credentials.
11
11
  - **Lunch Money API service:** the Lunch Money-owned V2 API, which receives the application's API requests, accepts access tokens, and checks that each request is permitted by the client's scopes.
12
12
 
13
- ## Users, budgeting accounts, and access tokens
13
+ ## Users, budget accounts, and access tokens
14
14
 
15
- A **Lunch Money user** is the person who signs in to Lunch Money. One user can have access to multiple **budgeting accounts**, such as a personal budget, a household budget, and a test budget. Each budgeting account contains its own financial data. Here, “budgeting account” means that collection of data, not an individual bank or manually managed account within it.
15
+ A **Lunch Money user** is the person who signs in to Lunch Money. One user can have access to multiple **budget accounts**, such as personal, household, and test budget accounts. Each budget account contains its own financial data. Here, “budget account” means that collection of data, not an individual bank or manually managed account within it.
16
16
 
17
- During OAuth authorization, the user selects one budgeting account and approves your client's permissions. The resulting **OAuth access token is specific to that Lunch Money user and budgeting account pair**, for your client. It does not grant access to every budgeting account the user can access.
17
+ During OAuth authorization, the user selects one budget account and approves your client's scopes. The resulting **OAuth access token is specific to that Lunch Money user and budget account pair**, for your client. It does not grant access to every budget account the user can access.
18
18
 
19
- For example, Alex can access both “Household” and “API testing.” If Alex selects “API testing” during authorization, your application's access token operates on that budgeting account. It cannot use the same token to read or update “Household.” Scopes determine which operations the application may perform within the selected account; they do not add access to other budgeting accounts.
19
+ For example, Alex can access both “Household” and “API testing.” If Alex selects “API testing” during authorization, your application's access token operates on that budget account. It cannot use the same token to read or update “Household.” Scopes determine which operations the application may perform within the selected account; they do not add access to other budget accounts.
20
20
 
21
- When applications store OAuth credentials, they should associate the authorization with the application user who started the flow and identify the connection by the Lunch Money user and budgeting account pair. Two Lunch Money users can both authorize access to the same shared budgeting account, so `account_id` alone is not a complete connection identity.
21
+ When applications store OAuth credentials, they should associate the authorization with the application user who started the flow and identify the connection by the Lunch Money user and budget account pair. Two Lunch Money users can both authorize access to the same shared budget account, so `account_id` alone is not a complete connection identity.
22
22
 
23
- ### Identify the authorized user and account
23
+ ### Identify the completed connection
24
24
 
25
- If your client has the `me:read` scope, call `GET /v2/me` with the access token. The response identifies both sides of the connection:
25
+ Your application cannot know which Lunch Money user or budget account completed authorization from browser state alone. Lunch Money may reuse an existing browser login session, and the authorization screen may let the person continue with a different Lunch Money user. A fresh or ephemeral browser request is also only an intent, not proof of identity.
26
+
27
+ After every successful code exchange, call `GET /v2/me` with the access token and confirm that the response contains the expected identifiers. It requires the `me:read` scope and identifies both sides of the completed connection:
26
28
 
27
29
  | Field | Meaning |
28
30
  | --- | --- |
29
31
  | `id` | The Lunch Money user's ID |
30
- | `account_id` | The selected budgeting account's ID |
31
- | `budget_name` | The selected budgeting account's display name |
32
+ | `account_id` | The selected budget account's ID |
33
+ | `budget_name` | The selected budget account's display name |
34
+
35
+ Use `account_id` as the stable identifier for the budget account and `id` as the identifier for the Lunch Money user who completed authorization. Together they identify one Lunch Money connection. If your application has its own user accounts, save each connection only for the person currently signed in to your application. A standalone native application without its own account system can store multiple connections locally, using each `id` and `account_id` pair as a connection identity. This lets one Lunch Money user connect multiple budget accounts and switch between them in the application. If the returned `id` changes, treat it as a user-identity change, not merely another budget account, and isolate the previous user's connections and cached data before showing the new identity.
36
+
37
+ Show `budget_name` so the application user can see which budget account they are using, but do not use it as a key: two budget accounts can have the same name. When names collide, add a secondary label such as the account ID only where the UI needs to distinguish them. Do not infer this identity from browser cookies, callback fields, `budget_name`, the user who was active before authorization, or token contents. Access tokens are opaque credentials; obtain the connection identity from the API response rather than parsing the token.
38
+
39
+ ### Select or authorize a budget account
40
+
41
+ Applications that may retain more than one Lunch Money identity should show the active Lunch Money user and which saved connection is the **active budget account**. Provide two distinct actions:
32
42
 
33
- Use `account_id` as the stable identifier for the budgeting account and `id` as the identifier for the Lunch Money user who completed authorization. Together they identify the Lunch Money side of the connection. For an application with its own accounts, store that pair within the authenticated application user's ownership boundary. A standalone native application without its own account system uses the `id` and `account_id` pair as its local connection identity.
43
+ - Select another saved connection belonging to the active Lunch Money user to switch the active budget account without starting OAuth again.
44
+ - Choose **Authorize another budget account** to start OAuth and connect a budget account that is not yet saved.
34
45
 
35
- Show `budget_name` so the application user can see which budget they are using, but do not use it as a key: two budgeting accounts can have the same name. When names collide, add a secondary label such as the account ID only where the UI needs to distinguish them. Access tokens are opaque credentials; obtain this information from the API response rather than parsing the token.
46
+ To connect to another Lunch Money user or budget account, send the user through authorization again and let Lunch Money handle login, user switching, and budget-account selection. Changing a locally stored account ID does not change which account an existing token can access. Refreshing a token renews access for its existing authorization; it does not select another budget account.
36
47
 
37
- ### Identify the user who completed authorization
48
+ Applications do not need a separate client-side “use another user” action. The ordinary **Authorize another budget account** action starts authorization, but the application cannot know which Lunch Money user and budget account the person will select. Identify the result only after the code exchange by calling `GET /v2/me`.
38
49
 
39
- Lunch Money may reuse an existing browser login session, and the authorization screen may let the person continue with a different Lunch Money user. Shared browser state therefore means that a login can be reused when available; it does not guarantee which user will complete authorization. A fresh or ephemeral browser request is also only an intent, not proof of identity.
50
+ ### Reconcile the authorization result
40
51
 
41
- After every successful code exchange, call and strictly validate `GET /v2/me`. Treat its `id` as the Lunch Money user who actually completed authorization and its `account_id` as the selected budgeting account. Do not infer that identity from browser cookies, callback fields, `budget_name`, the user who was active before authorization, or token contents.
52
+ After authorization, use the `id` and `account_id` returned by `GET /v2/me` to reconcile the result. If your application has its own user accounts, compare the result only with connections owned by the person currently signed in to your application.
42
53
 
43
- ### Select a different budgeting account
54
+ First, compare `id` with the active Lunch Money user:
44
55
 
45
- Applications that may retain more than one Lunch Money identity should show the active Lunch Money user and which saved connection is the **active budget**. Provide two distinct actions:
56
+ - If there is no active Lunch Money user, make the returned user active.
57
+ - If `id` identifies a different Lunch Money user, switch to that user before handling the budget account. Clear or isolate the previous user's displayed information and cached data, and hide that user's saved connections so none of it is available to the newly active user.
58
+ - If `id` matches the active Lunch Money user, continue using that user's saved connections.
46
59
 
47
- - Select another saved connection belonging to the active Lunch Money user to switch the active budget without starting OAuth again.
48
- - Choose **Authorize another budget** to start OAuth and connect a budgeting account that is not yet saved.
60
+ Then compare `account_id` with the active Lunch Money user's saved connections:
49
61
 
50
- To connect to a new, previously unauthorized, budgeting account, send the user through authorization again and have them select it. Changing a locally stored account ID does not change which account an existing token can access. Refreshing a token renews access for its existing authorization; it does not select another budgeting account.
62
+ - If it matches an existing connection, treat the result as a reconnection. Save the new access and refresh tokens together, so the connection never contains part of the old token set and part of the new one. Finish saving the complete replacement before using it.
63
+ - If it does not match an existing connection, create a connection for the newly authorized budget account.
51
64
 
52
- Applications do not need a separate client-side “use another user” action. The ordinary **Authorize another budget** action starts authorization; Lunch Money handles any login reuse or user switching. After `/v2/me` identifies the result, make that Lunch Money identity active and show only its connections. Clear or partition the previously displayed profile, configuration, and cached financial data before showing the new identity.
65
+ After reconciling the result, make the returned budget account active. It may be the user's first connection, another budget account they added, or an existing budget account they reauthorized. Authorizing another budget account does not revoke the user's other connections.
53
66
 
54
- Authorizing a second budgeting account for the same Lunch Money user creates or reuses that user's connection and does not revoke the first one. Update each connection's credentials and identity together, and keep cached data from one account separate from data loaded for another.
67
+ When the user chooses to switch between existing authorized budget accounts, select a saved connection only from the active Lunch Money identity and use that connection's stored access token to make API calls. All account-specific actions must use the active connection. Clear or partition cached financial data when the active connection changes. If the active connection is removed, select a documented remaining connection for the same Lunch Money user or enter a disconnected state. Never fall back to another user's hidden connection.
55
68
 
56
- ### Reauthorize an existing budgeting account
69
+ ### Optional: revoke a known connection before replacing it
57
70
 
58
- If authorization returns the same Lunch Money user `id` and budgeting-account `account_id` as an existing owned connection, treat it as a reconnection. Atomically replace that connection's stored access-token and refresh-token set with the credentials from the successful exchange. A different Lunch Money user authorizing the same shared `account_id` creates or updates a separate connection; it must not overwrite the first user's credentials.
71
+ Most applications do not need to revoke a connection before authorizing again. Use a separate revoke-first workflow only when the user deliberately chooses a known saved connection and wants to invalidate every copy of that authorization before replacing it. Send that connection's current refresh token to `POST /oauth/revoke`, then start authorization. See [Revoke access](/oauth/tokens#revoke-access).
59
72
 
60
- When the user chooses to switch between existing authorized budgets, select a saved connection only from the active Lunch Money identity and use that connection's stored access token to make API calls. All account-specific actions must use the active connection. Clear or partition cached financial data when the active connection changes so data from the previous budget is not shown under the new selection. If the active connection is removed, select a documented remaining connection for the same Lunch Money user or enter a disconnected state. Never fall back to another user's hidden connection.
73
+ Revocation disconnects the selected connection immediately, including when the user abandons authorization or selects a different Lunch Money user or budget account. When authorization completes, reconcile the result using the rules above instead of assuming it replaces the connection that initiated the flow. Never wait until after the exchange to revoke the previous refresh token, because that would also revoke the newly issued credentials when Lunch Money reused the same underlying authorization.
61
74
 
62
75
  ### Retain connections for an inactive Lunch Money user
63
76
 
64
77
  An application may retain credentials for a Lunch Money user who is not currently active when its application-user ownership model permits it. Switching identities should hide the previous user's connections and clear or partition that user's displayed data, but hiding a connection does not revoke it or delete its stored credentials. If that Lunch Money user authorizes again later, the application may make the user's retained connections visible again.
65
78
 
66
- An application may instead delete stored credentials as part of its own sign-out or user-switch policy. Make that policy understandable in the interface. In particular, distinguish disconnecting or remotely revoking a budgeting-account authorization from forgetting its local credential without revoking remote access.
79
+ An application may instead delete stored credentials as part of its own sign-out or user-switch policy. Make that policy understandable in the interface. In particular, distinguish disconnecting or remotely revoking a budget-account authorization from forgetting its local credential without revoking remote access.
67
80
 
68
81
  ## Client types and credentials
69
82
 
70
83
  When a developer registers a client, they must choose a client type based on whether the application code can keep a client secret secure. This choice cannot be changed after the client is registered. The developer selects either **Confidential web client** or **Native or public client**.
71
84
 
72
- - **Confidential web client:** Runs on a server and can securely store client secrets. In OAuth terminology, this is called a *confidential client*. Choose this type for a web application—or any other application architecture with a centralized server. Its client secret helps Lunch Money verify that a token request came from the application that registered the client. The client secret and refresh tokens must stay on the server. The application must protect access tokens wherever its architecture uses them, and associate each authorization with the correct application user and authorized Lunch Money budgeting account.
73
- - **Native or public client:** Runs on a user-controlled device and uses PKCE without a client secret because installed application code cannot keep a secret secure. In OAuth terminology, this is called a *native public client*. Choose this type for a standalone mobile or desktop application. The app stores each user's tokens securely on that user's device—for example, in Keychain on Apple platforms or appropriate Keystore-backed storage on Android—and must avoid exposing them through backups, logs, or application data shared with other apps.
85
+ - **Confidential web client:** Runs on a server and can securely store client secrets. In OAuth terminology, this is called a *confidential client*. Choose this type for a web application—or any other application architecture with a centralized server. Its client secret helps Lunch Money verify that a token request came from the application that registered the client. The client secret and refresh tokens must stay on the server. The application must protect access tokens wherever its architecture uses them, and associate each authorization with the correct application user and authorized Lunch Money budget account.
86
+ - **Native or public client:** Runs on a user-controlled device and uses Proof Key for Code Exchange (PKCE) without a client secret because installed application code cannot keep a secret secure. In OAuth terminology, this is called a *native public client*. Choose this type for a standalone mobile or desktop application. The app stores each user's tokens securely on that user's device—for example, in Keychain on Apple platforms or appropriate Keystore-backed storage on Android—and must avoid exposing them through backups, logs, or application data shared with other apps.
74
87
 
75
- These client families are not interchangeable. A confidential server-side sample cannot be moved into a native application by embedding its client secret or server-held credentials; use a native-client flow and platform secure storage instead.
88
+ These client types are not interchangeable. A confidential server-side sample cannot be moved into a native application by embedding its client secret or server-held credentials; use a native-client flow and platform secure storage instead.
76
89
 
77
- Every client receives a client ID that identifies its Lunch Money registration. The client ID is not secret. Both client types also use Proof Key for Code Exchange (PKCE) to bind the authorization response to the application that started the flow.
90
+ Every client receives a client ID that identifies its Lunch Money registration. The client ID is not secret. Both client types use PKCE to bind the authorization response to the application that started the flow.
78
91
 
79
92
  ## Redirect URIs
80
93
 
@@ -84,9 +97,9 @@ The developer registers each permitted redirect URI in advance. For a confidenti
84
97
 
85
98
  ## Scopes and least privilege
86
99
 
87
- Resource scopes such as `transactions:read` authorize specific ways of working with Lunch Money data. A scope generally applies to a particular kind of action—such as reading or updating a resource—and only to the relevant API endpoints. Permissions are independent: for example, `transactions:update` does not also grant `transactions:read`.
100
+ Scopes are named permissions that define what an OAuth client may do with Lunch Money data. Resource scopes such as `transactions:read` authorize a particular kind of action—such as reading or updating a resource—and only for the relevant API endpoints. Scopes are independent: for example, `transactions:update` does not also grant `transactions:read`.
88
101
 
89
- The [V2 API reference](/v2/docs) identifies the scope required by each API endpoint. Use it together with the [scope catalog](/oauth/scopes) to select the permissions your application's features require.
102
+ The [V2 API reference](/v2/docs) identifies the OAuth scope requirements for each operation. An operation may require one scope, several scopes together, or additional scopes when a request enables broader behavior. Review the operation and relevant parameter descriptions, then use the [OAuth scopes](/oauth/scopes) page to select the scopes your application's features require.
90
103
 
91
104
  Scopes are selected when the client is created and cannot be edited later. Every user who authorizes that client sees and grants all—and only—the scopes the developer selected. To change them, create and test a replacement client, complete review when applicable, update your integration, and ask existing users to authorize again. Existing authorizations and tokens do not move to the replacement client.
92
105
 
@@ -5,11 +5,13 @@ Use this guide after you have [registered a client](/oauth/register-client) and
5
5
  The goal now is to test that complete workflow—including its failure and recovery paths—before asking Lunch Money to approve the application for other users.
6
6
 
7
7
  > [!NOTE] Development access is owner-only
8
- > While an OAuth client is in development, only the Lunch Money user who owns it can authorize the application. Your team should have the developer doing most of the initial Lunch Money work create and own the client so they can test the complete flow with their budgeting accounts. Other team members cannot authorize the application until the client has been reviewed and approved.
8
+ > While an OAuth client is in development, only the Lunch Money user who owns it can authorize the application. Your team should have the developer doing most of the initial Lunch Money work create and own the client so they can test the complete flow with their budget accounts. Other team members cannot authorize the application until the client has been reviewed and approved.
9
+
10
+ Owner-only testing is enough to submit a client for review. You do not need beta-tester coverage before submission; test the complete flow and recovery behavior with the owner's Lunch Money user and test budget accounts.
9
11
 
10
12
  ## Set up a safe test environment
11
13
 
12
- Use a separate Lunch Money test budgeting account when exercising create, update, or delete operations. The [Getting Started guide](/getting-started#create-a-test-budgeting-account) walks through creating one and adding sample data.
14
+ Use a separate Lunch Money test budget account when exercising create, update, or delete operations. The [Getting Started guide](/getting-started#create-a-test-budget-account) walks through creating one and adding sample data.
13
15
 
14
16
  Keep production client secrets, tokens, and user data out of test fixtures, logs, screenshots, and bug reports.
15
17
 
@@ -30,42 +32,42 @@ You may choose any available port, but the complete redirect URI sent during aut
30
32
  The user's browser—not Lunch Money's server—connects to the loopback listener. Keep PKCE and `state` protections in place just as you would for a hosted callback. Before requesting review, also register the HTTPS callback used by the deployed application; the loopback URI can remain available for local testing. After approval, you can add or keep a loopback redirect as long as that production HTTPS callback remains. See [after approval](/oauth/review-and-approval#after-approval).
31
33
 
32
34
  > [!NOTE] Test an approved client with your development team
33
- > After a client is approved, other team members can continue developing and testing the application's Lunch Money functionality. You can add or keep a loopback redirect on the approved client as long as the production HTTPS callback remains. If a loopback redirect is registered, each developer who can run the application locally may authorize access to their own Lunch Money budgeting account. The client ID is public, but developers working on a confidential web client also need access to its client secret through your team's secure credential-management process. Do not share access tokens or refresh tokens between developers.
35
+ > After a client is approved, other team members can continue developing and testing the application's Lunch Money functionality. You can add or keep a loopback redirect on the approved client as long as the production HTTPS callback remains. If a loopback redirect is registered, each developer who can run the application locally may authorize access to their own Lunch Money budget account. The client ID is public, but developers working on a confidential web client also need access to its client secret through your team's secure credential-management process. Do not share access tokens or refresh tokens between developers.
34
36
 
35
37
  ## Repeat or reset authorization
36
38
 
37
- During development, the client owner can run authorization again whenever they want to repeat the sign-in, budgeting-account selection, consent, and callback flow. They do not need to revoke the current token first. The authorization server may reuse the current browser login or let the person continue with a different Lunch Money user. Treat the validated `/v2/me` user/account pair—not previous browser state—as the completed authorization's identity.
39
+ During development, the client owner can run authorization again whenever they want to repeat the sign-in, budget-account selection, consent, and callback flow. They do not need to revoke the current token first. The authorization server may reuse the current browser login or let the person continue with a different Lunch Money user. Treat the validated `/v2/me` user/account pair—not previous browser state—as the completed authorization's identity.
38
40
 
39
41
  To test how the application responds after access is revoked, revoke the current token and make another API request with it. Lunch Money should reject the request, and the application should discard its saved credentials and begin authorization again. The [token revocation guide](/oauth/tokens#revoke-access) includes copyable `curl` requests for development testing.
40
42
 
41
43
  ## Test the complete client
42
44
 
43
- Test with one Lunch Money user authorizing multiple budgeting accounts, then with a second Lunch Money user authorizing through the same browser or device. For a client registered with `me:read`, strictly validate the returned `id` and `account_id` after every exchange. Store credentials under the authenticated application user and that Lunch Money user/account pair. For a standalone app without its own accounts, use the Lunch Money user/account pair as the local connection identity.
45
+ Test with one Lunch Money user authorizing multiple budget accounts, then with a second Lunch Money user authorizing through the same browser or device. For a client registered with `me:read`, strictly validate the returned `id` and `account_id` after every exchange. Store credentials under the authenticated application user and that Lunch Money user/account pair. For a standalone app without its own accounts, use the Lunch Money user/account pair as the local connection identity.
44
46
 
45
47
  1. Complete authorization. For each attempt, your application should create a random `state` value, save it with the application user's session, and verify that Lunch Money returns the same value to the callback. Rejecting a missing, changed, or reused value prevents a callback started elsewhere from being attached to the wrong session.
46
48
  2. Keep the PKCE verifier with that same authorization attempt and use it when exchanging the returned code. Confirm that an exchange with a missing or changed verifier fails; this prevents someone who intercepts the code from using it.
47
49
  3. Read the token response's `scope` field and confirm that it contains the complete scope set registered for the client. Do not inspect or parse the access token itself.
48
- 4. Call every scope-dependent feature, including negative permission cases.
50
+ 4. Call every scope-dependent feature, including insufficient-scope cases.
49
51
  5. Test user denial, missing or changed `state`, callback errors, and interrupted authorization attempts. Confirm that denial or a failed `/v2/me` validation leaves all existing connections unchanged.
50
52
  6. Make `GET /v2/me` fail or return an invalid shape after a successful exchange. Confirm that the application saves no unidentified or partial connection.
51
53
  7. Reauthorize an already connected Lunch Money user/account pair. Confirm that the application atomically replaces that connection's credentials, makes it active, and does not create a duplicate.
52
- 8. Authorize as a second Lunch Money user through the same browser or device. Confirm that the previously displayed profile, configuration, saved-budget choices, and cached financial data disappear, while any retained credentials remain hidden.
54
+ 8. Authorize as a second Lunch Money user through the same browser or device. Confirm that the previously displayed profile, configuration, saved-connection choices, and cached financial data disappear, while any retained credentials remain hidden.
53
55
  9. Return to the first Lunch Money user. Confirm that only that user's retained connections become visible again and that the other user's connections cannot be selected.
54
56
  10. Have two different Lunch Money users independently authorize the same shared `account_id`. Confirm that the application stores separate credentials keyed by Lunch Money user `id` and `account_id`, without overwriting either connection.
55
- 11. Give two visible budgets the same `budget_name`. Confirm that they remain separate by `account_id` and that the UI disambiguates them only where needed without using the name as a key.
57
+ 11. Give two visible budget accounts the same `budget_name`. Confirm that they remain separate by `account_id` and that the UI disambiguates them only where needed without using the name as a key.
56
58
  12. Attempt to select a connection belonging to an inactive Lunch Money user. Confirm that the request is rejected before credentials or cached data are loaded.
57
- 13. Switch the active budget and exercise API calls, refresh, revocation, and local deletion. Confirm that each action and every cache entry affects only the active user/account connection.
58
- 14. Remove the active Lunch Money user's final budget. Confirm that the application enters a disconnected state rather than exposing or selecting another user's hidden connection.
59
+ 13. Switch the active budget account and exercise API calls, refresh, revocation, and local deletion. Confirm that each action and every cache entry affects only the active user/account connection.
60
+ 14. Remove the active Lunch Money user's final budget account. Confirm that the application enters a disconnected state rather than exposing or selecting another user's hidden connection.
59
61
  15. Test remote disconnect and local-only credential deletion separately. Confirm local-only deletion, explain that the remote authorization remains active, and keep unrelated connections unchanged.
60
62
 
61
63
  ## Test reauthorization before refresh
62
64
 
63
65
  First make sure your application can recover without a refresh token. Record when the token response arrives and use `expires_in` to determine when the access token is expected to expire. After it expires, make a harmless API request and confirm that Lunch Money returns an authentication failure identifying the token as invalid.
64
66
 
65
- Your application should discard the unusable token for that connection and start authorization again. Confirm that the same application user can complete the flow, select the intended budgeting account, and continue using that connection with the replacement token. This recovery path is required when a client does not have `offline_access`, and it remains the fallback when a refresh token expires, is revoked, or otherwise stops working. Keep other connections usable while this one recovers.
67
+ Your application should discard the unusable token for that connection and start authorization again. Confirm that the same application user can complete the flow, select the intended budget account, and continue using that connection with the replacement token. This recovery path is required when a client does not have `offline_access`, and it remains the fallback when a refresh token expires, is revoked, or otherwise stops working. Keep other connections usable while this one recovers.
66
68
 
67
69
  After reauthorization works, clients registered with `offline_access` can add and test refresh-token handling. Verify replacement-token storage, concurrent-refresh protection, revocation, and terminal refresh recovery before relying on unattended operation. See [token lifecycle and recovery](/oauth/tokens).
68
70
 
69
- Finally, add a production HTTPS redirect and complete the [review checklist](/oauth/review-and-approval).
71
+ Finally, complete the [review checklist](/oauth/review-and-approval). A confidential web client needs a production HTTPS redirect before review. A native client may be submitted with an eligible native redirect and an accessible pre-release build.
70
72
 
71
73
  Next: [Operate securely](/oauth/security).
@@ -2,29 +2,32 @@
2
2
 
3
3
  OAuth lets your application access Lunch Money on behalf of a user without asking that person to copy and share a personal access token. **If you are building an application for anyone other than yourself, use OAuth.** It gives each user a familiar Lunch Money sign-in and consent experience while keeping their personal access token out of your application.
4
4
 
5
- ![OAuth authorization-code flow across your application, the Lunch Money user, and Lunch Money. The application redirects the user's browser, Lunch Money handles sign-in and presents the budgeting-account and permission choices, the user approves access, Lunch Money returns an authorization code, and the application exchanges it for tokens, calls GET /v2/me, saves the identified connection, and calls the API for that account.](/v2/images/oauth-authorization-flow.svg)
5
+ > [!NOTE] OAuth requires the v2 API
6
+ > OAuth access tokens are not supported by v1 endpoints. If an existing application uses v1, [migrate it to v2](/v2/migration-guide) before adding OAuth.
7
+
8
+ ![OAuth authorization-code flow across your application, the Lunch Money user, and Lunch Money. The application redirects the user's browser, Lunch Money handles sign-in and presents the budget-account and scope choices, the user approves access, Lunch Money returns an authorization code, and the application exchanges it for tokens, calls GET /v2/me, saves the identified connection, and calls the API for that account.](/v2/images/oauth-authorization-flow.svg)
6
9
 
7
10
  ## Choose OAuth or a personal access token
8
11
 
9
12
  | Question | Personal access token | OAuth client |
10
13
  | --- | --- | --- |
11
- | Whose data can it access? | One budgeting account belonging to the user who created the token | One budgeting account selected by each user who authorizes the application |
14
+ | Whose data can it access? | One budget account belonging to the user who created the token | One budget account selected by each user who authorizes the application |
12
15
  | Best fit | API exploration, one-off scripts, and short-lived work on your own account | Persistent integrations and applications intended for other users |
13
- | How is access granted? | The user creates a token on the [Developers page](https://my.lunchmoney.app/developers) in the Lunch Money web app | The user signs in and approves the permissions requested by the application |
16
+ | How is access granted? | The user creates a token on the [Developers page](https://my.lunchmoney.app/developers) in the Lunch Money web app | The user signs in and approves the scopes requested by the application |
14
17
  | Credential handling | The user keeps the token and sends it with their own API requests; third-party applications should use OAuth instead of asking users to share one | The authorization flow delivers application-specific tokens without asking for a personal token |
15
- | Permissions | Full access to the Lunch Money APIs available for that budgeting account, with no fine-grained permission controls | Only the permissions selected when the OAuth client was registered |
18
+ | Scopes | Full access to the Lunch Money APIs available for that budget account, with no fine-grained scope controls | Only the scopes selected when the OAuth client was registered |
16
19
  | Lifecycle | Created and revoked by the user | Short-lived access tokens and optional finite refresh access; the user can revoke the application's access |
17
20
 
18
21
  Personal access tokens remain useful for quick work on your own account. OAuth is the recommended model for applications and integrations that other Lunch Money users will connect to, as well as automations that need to run over time.
19
22
 
20
23
  ## What limits access
21
24
 
22
- An OAuth client is an application's registration with Lunch Money. When a developer registers the client, they select the scopes—the specific permissions—the application needs. Later, when a Lunch Money user authorizes the application, Lunch Money shows them that complete permission set before they approve access. Choose only the permissions the application's features require. A focused permission request is easier for users to understand and trust, and reduces the risk of the application reading or changing data it does not need.
25
+ An OAuth client is an application's registration with Lunch Money. When a developer registers the client, they select the scopes—the specific permissions—the application needs. Later, when a Lunch Money user authorizes the application, Lunch Money shows them that complete scope set before they approve access. Choose only the scopes the application's features require. A focused scope request is easier for users to understand and trust, and reduces the risk of the application reading or changing data it does not need.
23
26
 
24
- One Lunch Money user can have multiple budgeting accounts and multiple connections to the same OAuth client. Each OAuth access token represents that user and the single budgeting account they selected during authorization. It does not provide access to all of their budgets. Read [users, budgeting accounts, and access tokens](/oauth/concepts#users-budgeting-accounts-and-access-tokens) for an example and how to identify the connected account.
27
+ One Lunch Money user can have multiple budget accounts and multiple connections to the same OAuth client. Each OAuth access token represents that user and the single budget account they selected during authorization. It does not provide access to all of their budget accounts. Read [users, budget accounts, and access tokens](/oauth/concepts#users-budget-accounts-and-access-tokens) for an example and how to identify the connected account.
25
28
 
26
29
  ## Before you start
27
30
 
28
31
  You need an active Lunch Money account to [register and manage an OAuth client](/oauth/applications) for your application. During development, only the client owner can authorize the application. Approval is required before other Lunch Money users can authorize it.
29
32
 
30
- Start with [OAuth concepts](/oauth/concepts), [register a client](/oauth/register-client), and then [implement the authorization-code flow](/oauth/authorization-code). You can also run the [confidential Node.js sample application](/oauth/sample-applications) to see registration, authorization, an API call, revocation, and local reset working together. Use the [scope catalog](/oauth/scopes) to plan permissions and [troubleshooting](/oauth/troubleshooting) when a flow fails.
33
+ Start with [OAuth concepts](/oauth/concepts), [register a client](/oauth/register-client), and then [implement the authorization-code flow](/oauth/authorization-code). You can also run the [confidential Node.js sample application](/oauth/sample-applications) to see registration, authorization, an API call, revocation, and local reset working together. Use [OAuth scopes](/oauth/scopes) to plan the client's scopes and [troubleshooting](/oauth/troubleshooting) when a flow fails.