Skip to content

Commit 5ba0aab

Browse files
committed
Support alternative Pocket servers (Pocket is shutting down)
1 parent f896f77 commit 5ba0aab

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,16 @@ yarn install
6868
yarn start
6969
```
7070

71+
## Configuration
72+
73+
Pocket's official service ends on July 8, 2025. To use news2reader with an API-compatible Pocket alternative,
74+
you can override the following two environment variables (e.g. in your `docker-compose.yml`):
75+
76+
| Environment variable name | Default value |
77+
| ------------------------- | -------------------------------- |
78+
| `POCKET_BASE_URL` | `https://getpocket.com` |
79+
| `POCKET_API_CONSUMER_KEY` | `108332-4cb01719bb01deabce69438` |
80+
7181
## How to use it
7282

7383
Start by opening the homepage in a web browser to make sure the application is running as expected.

src/provider/pocket.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ export default class PocketProvider {
6262
private accessToken: string | null;
6363
private authConfigPath: string;
6464

65-
private readonly CONSUMER_KEY = "108332-4cb01719bb01deabce69438";
65+
// Allow env var overrides to point to custom Pocket-compatible servers
66+
public readonly BASE_URL = process.env.POCKET_BASE_URL ?? "https://getpocket.com";
67+
private readonly CONSUMER_KEY = process.env.POCKET_API_CONSUMER_KEY ?? "108332-4cb01719bb01deabce69438";
6668
private readonly BASE_SEARCH_PARAMS: PocketApiSearchParams = {
6769
detailType: "simple",
6870
count: 60,
@@ -122,7 +124,7 @@ export default class PocketProvider {
122124
const redirectUrl = `http://${req.headers.host}/pocket/oauth`;
123125
try {
124126
const data = (await got
125-
.post("https://getpocket.com/v3/oauth/request", {
127+
.post(`${this.BASE_URL}/v3/oauth/request`, {
126128
headers: {
127129
Accept: "*/*",
128130
"X-Accept": "application/json",
@@ -139,7 +141,7 @@ export default class PocketProvider {
139141
request_token: this.code,
140142
redirect_uri: redirectUrl,
141143
});
142-
const authorizeUrl = `https://getpocket.com/auth/authorize?${authorizeQuery}`;
144+
const authorizeUrl = `${this.BASE_URL}/auth/authorize?${authorizeQuery}`;
143145
res.redirect(authorizeUrl);
144146
return;
145147
} catch (e) {
@@ -152,7 +154,7 @@ export default class PocketProvider {
152154
// We should now be able to exchange our 'code' for an access token
153155
try {
154156
const data = (await got
155-
.post("https://getpocket.com/v3/oauth/authorize", {
157+
.post(`${this.BASE_URL}/v3/oauth/authorize`, {
156158
headers: {
157159
Accept: "*/*",
158160
"X-Accept": "application/json",
@@ -285,7 +287,7 @@ export default class PocketProvider {
285287

286288
private async getStories(searchParams: PocketApiSearchParams) {
287289
const data = await got
288-
.post("https://getpocket.com/v3/get", {
290+
.post(`${this.BASE_URL}/v3/get`, {
289291
headers: {
290292
Accept: "*/*",
291293
"X-Accept": "application/json",

src/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ app.get("/", async (req: Request, res: Response) => {
137137
<p>Not yet supported</h3>
138138
<h3>Tildes.net</h3>
139139
<p>Not yet supported</h3>
140-
<h3>Pocket</h3>
140+
<h3>Pocket-compatible server at ${pocketProvider.BASE_URL}</h3>
141141
${pocketHtml}
142142
</body>
143143
`;

0 commit comments

Comments
 (0)