You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 09c0bd3
Browse filesBrowse the repository at this point in the historyBrowse files
Move app-client-starter-app under samples/ and update CI, Dependabot and
README paths to match. While here, fix the inconsistencies found in a
review pass:
- Remove references to docs that don't exist
- Drop the app-level LICENSE so the root MIT license covers everything
- Move CONTRIBUTING.md to the root and state what contributions we accept
- Rename the npm package from buffer-app to app-client-starter-app
- Describe the rate-limit handling as it actually works
- Remove PORT from .env.example
- Clarify a misleading test name and fixture
- Add a samples table to the root README and clean up formatting
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A collection of sample applications that show how to build on the Buffer API. Each sample is a small, self-contained project you can clone, run, and use as a starting point for your own build.
3
4
4
5
> **Note:** These samples are meant for learning and prototyping. Make sure to review and adapt them to your own security, error-handling, and scaling needs before using them in production.
5
6
6
-
### Prerequisites
7
-
7
+
## Samples
8
+
9
+
| Sample | What it shows | Stack |
10
+
| --- | --- | --- |
11
+
|[App client starter app](samples/app-client-starter-app)| A third-party app that connects a Buffer account over OAuth 2.0 with PKCE, lists its channels, and adds a draft post to a channel's queue. | Node.js, Express |
12
+
13
+
## Prerequisites
14
+
8
15
- A [Buffer](https://buffer.com) account
9
-
- API access credentials - see the [Buffer developer docs](https://developers.buffer.com/guides/authentication.html) for how to get them
16
+
- API access credentials. See the [Buffer developer docs](https://developers.buffer.com/guides/authentication.html) for how to get them.
10
17
- Any language-specific tooling listed in the sample's own README
11
18
12
19
## Repository structure
13
-
14
-
Each sample app lives in its own folder with everything it needs to run:
15
-
20
+
21
+
All sample apps live in the `samples/` directory. Each one has its own folder with everything it needs to run:
22
+
16
23
```
17
24
.
18
-
├── sample-app-name/
19
-
│ ├── README.md # Setup and usage instructions for this sample
20
-
│ ├── .env.example # Environment variables the sample needs
21
-
│ └── ... # Source code
22
-
├── another-sample/
23
-
│ └── ...
25
+
├── samples/
26
+
│ ├── sample-app-name/
27
+
│ │ ├── README.md # Setup and usage instructions for this sample
28
+
│ │ ├── .env.example # Environment variables the sample needs
These sample apps are provided as-is for educational purposes. They're maintained on a best-effort basis and aren't covered by Buffer's product support or service-level agreements.
53
62
54
-
We welcome issues and suggestions for improvements. If you spot a bug or have an idea for a new sample, please [open an issue](../../issues). At the moment we don't accept direct contributions of new samples.
63
+
These sample apps are provided as-is for educational purposes. They're maintained on a best-effort basis and aren't covered by Buffer's product support or service-level agreements.
64
+
65
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for what we accept and how to contribute.
55
66
56
67
## License
57
-
This project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for details.
58
68
69
+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
Copy file name to clipboardExpand all lines: samples/app-client-starter-app/README.md
+13-20Lines changed: 13 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,9 @@
1
1
# Draft Queue: a Buffer app client example
2
2
3
-
A small, runnable example of a third-party app built on the [Buffer API](https://developers.buffer.com).
4
-
3
+
A small, runnable example of a third-party app built on the [Buffer API](https://developers.buffer.com).
5
4
6
5
## What it does
6
+
7
7
It's a small starter app called Draft Queue which covers key components of an app client:
8
8
9
9
1. A user connects their own Buffer account over OAuth 2.0 (Authorization Code + PKCE).
@@ -14,7 +14,6 @@ It's a small starter app called Draft Queue which covers key components of an ap
14
14
15
15
Use it as a starting point for your own integration. Clone it, configure it with your own app client, build new features on top, or share it with your AI coding agent as a reference.
16
16
17
-
18
17
## Prerequisites
19
18
20
19
- Node.js 22
@@ -27,7 +26,7 @@ Use it as a starting point for your own integration. Clone it, configure it with
27
26
1. From the root of the repository, move into this sample:
28
27
29
28
```bash
30
-
cd app-client-starter-app
29
+
cdsamples/app-client-starter-app
31
30
```
32
31
33
32
2. Install dependencies:
@@ -61,11 +60,11 @@ Use it as a starting point for your own integration. Clone it, configure it with
61
60
62
61
5. Run the app locally:
63
62
64
-
```bash
65
-
npm start
66
-
```
63
+
```bash
64
+
npm start
65
+
```
67
66
68
-
Open `https://localhost:3000` and accept the self-signed development certificate in your browser.
67
+
Open `https://localhost:3000` and accept the self-signed development certificate in your browser.
69
68
70
69
## Project structure
71
70
@@ -76,27 +75,21 @@ Open `https://localhost:3000` and accept the self-signed development certificate
76
75
|`server.js`| Local HTTPS dev server. |
77
76
|`api/index.js`, `vercel.json`| Serverless entry point and routing, using Vercel as an example host. |
78
77
|`test/`| Regression tests for the protocol and security-critical helpers. |
79
-
|`docs/`|Architecture notes and the production OAuth guide. |
78
+
|`docs/`|The demo GIF used in this README. |
80
79
|`scripts/`| Generates the self-signed certificate for local HTTPS. |
81
80
82
81
## What this example covers
83
-
82
+
84
83
-**OAuth 2.0 with PKCE:** the full Authorization Code flow with PKCE. It sends the user to Buffer to authorize the app, handles the redirect back, and exchanges the authorization code for tokens. See `lib/buffer.js`.
85
84
-**GraphQL requests:** authenticated calls to the Buffer GraphQL API. The app reads the user's organization and channels, then runs a mutation that creates a draft post in a channel's queue.
86
85
-**Refresh tokens:** the app requests the `offline_access` scope, so Buffer returns a refresh token alongside the access token. When the access token expires, the app renews it without asking the user to sign in again. Both tokens are sealed inside an HttpOnly cookie, so browser JavaScript can never read them.
87
-
-**Staying within rate limits:** the app reads the rate limit headers on each response and uses them to stay within the limits applied to the client.
88
-
-**Deployment:** a working setup for Vercel (`api/index.js` and `vercel.json`) shows how to run the same app as a serverless deployment. You can adapt it to any Node.js host.
-**Handling rate limits:** rate limits apply per app client, so every user of the app shares one quota. When Buffer responds with HTTP 429, the app reads the `Retry-After` header. If the wait is 5 seconds or less, it waits and retries the request once. Otherwise it returns the error to the user with the wait time. See `graphql()` in `lib/buffer.js`.
87
+
-**Deployment:** a working setup for Vercel (`api/index.js` and `vercel.json`) shows how to run the same app as a serverless deployment. If you deploy from this repository, set the project's root directory to `samples/app-client-starter-app`. You can adapt it to any Node.js host.
95
88
96
89
## Support and contributing
97
90
98
-
This sample is provided as-is for educational purposes and isn't covered by Buffer's product support or service-level agreements. If you find a bug or something out of date, please [open an issue](../../../issues). See the [repository README](../README.md#contributing) for how we handle contributions.
91
+
This sample is provided as-is for educational purposes and isn't covered by Buffer's product support or service-level agreements. If you find a bug or something out of date, please [open an issue](../../../../issues). See [CONTRIBUTING.md](../../CONTRIBUTING.md) for how we handle contributions.
99
92
100
93
## License
101
94
102
-
This sample is licensed under the MIT License. See the [LICENSE](../LICENSE) file at the root of the repository.
95
+
This sample is licensed under the MIT License. See the [LICENSE](../../LICENSE) file at the root of the repository.
0 commit comments