Skip to content

[RedditBridge] Use OAuth2 token and endpoint for accessing the JSON API - #5039

Open
Electronic-Mango wants to merge 3 commits into
RSS-Bridge:masterfrom
Electronic-Mango:master
Open

[RedditBridge] Use OAuth2 token and endpoint for accessing the JSON API#5039
Electronic-Mango wants to merge 3 commits into
RSS-Bridge:masterfrom
Electronic-Mango:master

Conversation

@Electronic-Mango

@Electronic-Mango Electronic-Mango commented Jul 13, 2026

Copy link
Copy Markdown

Allow users to specify their own Reddit utility script app credentials to use OAuth2 authorized version of the API, since Reddit disabled unauthenticated JSON requests.

The new parameters are configured through config.php.ini and RedditBridge specific configuration:

[RedditBridge]
app_id = "<ID>"
app_secret = "<secret>"

"Solves" #4866 and #3802, however there are two problems:

  1. Instance-specific configuration required private instances of RSS-Bridge.
  2. Reddit blocked creating the legacy script apps. Now they require submitting a request and getting an approval. Already existing apps seem to work fine.

As for 1. - I'm not sure if there's a different approach, than private instances. I could modify the bridge to require those credentials via regular bridge parameters, but passing secrets through query seems like a bad idea.

As for 2. - I'm not even sure if it's worth merging such change, as it's impossible to use the bridge without having already working app. The bridge does work if you do, but you can't get it working if you didn't create the app in the past.

Due to this I'm creating it as draft for now, but perhaps it will be useful for someone with already existing app.

Add Reddit authorization via OAuth2 and legacy developer script "app".
Username/password (or app ID/secret) are read from "config.ini.php",
as configuration specific to RedditBridge.
On first 401/403 try to refresh the OAuth2 token and try to send
the request one more time.
@github-actions

Copy link
Copy Markdown

Pull request artifacts

Bridge Context Status
Reddit 1 single (current) HTTP status 429 Too Many Requests
Type: RateLimitException
Message:
Reddit 1 single (pr) Bridge returned error 401! (20647)
Type: HttpException
Message: https://www.reddit.com/api/v1/access_token resulted in 401 Unauthorized
Reddit 2 multi (current) HTTP status 429 Too Many Requests
Type: RateLimitException
Message:
Reddit 2 multi (pr) Bridge returned error 401! (20647)
Type: HttpException
Message: https://www.reddit.com/api/v1/access_token resulted in 401 Unauthorized
Reddit 3 user (current) HTTP status 429 Too Many Requests
Type: RateLimitException
Message:
Reddit 3 user (pr) Bridge returned error 401! (20647)
Type: HttpException
Message: https://www.reddit.com/api/v1/access_token resulted in 401 Unauthorized

last change: Monday 2026-07-13 22:25:25

@dvikan

dvikan commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

@Electronic-Mango @dawidsowa

hmm maybe a new bridge for this

i prefer a new class RedditClient

RedditClient handles search requests and OAuth2 token management.
When both app_id and app_secret are configured, it uses OAuth2
through custom Reddit "app"; otherwise it falls back to the legacy
unauthenticated endpoint.
@Electronic-Mango

Copy link
Copy Markdown
Author

@dvikan I moved the "access" logic into dedicated RedditClient class. If both app_id and app_secret are passed into the bridge, then the client will use the OAuth access bearer; if either, or both, are missing, then the client falls back to the legacy access. This way the bridge's behavior should change only if the app credentials are configured.

I thought about splitting the bridge into two, but the majority of the logic would be exactly the same, so I went with the dynamic behavior of the client for now.

@Electronic-Mango
Electronic-Mango marked this pull request as ready for review August 14, 2026 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants