Skip to content

Commit

Permalink
Prepare for API client id change
Browse files Browse the repository at this point in the history
Add notice of client id changes and prep testing for the changes.
  • Loading branch information
OMEGARAZER committed Jun 17, 2023
1 parent 26e70c2 commit a68341f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
- name: Make configuration for tests
env:
REDDIT_CLIENT: ${{ secrets.REDDIT_CLIENT_ID }}
REDDIT_TOKEN: ${{ secrets.REDDIT_TEST_TOKEN }}
run: |
./devscripts/configure${{ matrix.ext }}
Expand Down
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![PyPI Status](https://img.shields.io/pypi/status/bdfrx?logo=PyPI)](https://pypi.python.org/pypi/bdfrx)
[![PyPI version](https://img.shields.io/pypi/v/bdfrx.svg?logo=PyPI)](https://pypi.python.org/pypi/bdfrx)
[![Python Test](https://github.com/OMEGARAZER/bulk-downloader-for-reddit-x/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/OMEGARAZER/bulk-downloader-for-reddit-x/actions/workflows/test.yml)
[![linting: Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json&label=linting)](https://github.com/charliermarsh/ruff)
[![linting: Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json&label=linting)](https://github.com/astral-sh/ruff)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg?logo=Python)](https://github.com/psf/black)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)

Expand Down Expand Up @@ -45,8 +45,15 @@ BDFRx differs from the base BDFR in a few ways:

- Does not contain the Archive and Clone modes (If you require these modes you can try v0.9.1, provided *as is* or use the base [BDFR](https://github.com/aliparlakci/bulk-downloader-for-reddit) project)
- Option to use an Sqlite3 database to store hashes, links and post ID's to be filtered in future runs
- Uses the `bdfrx` config directory by default as well as a different client_id which does not require the use of the client_secret
- You will not be able to use the BDFR id/secret/token, you will need to authorize with the new client_id
- Uses the `bdfrx` config directory by default

## Reddit API Changes

Starting July 1st 2023 ([along with the other changes](https://reddit.com/12qwagm)) rate limits will be [applied ***per client id*** rather than by client id/user combination](https://reddit.com/13wsiks). Therefore it is no longer tenable to ship BDFRx with an installed client id as it will cause rate limiting for all users. **The shipped client id will no longer be valid after the changes.**

To create your own for use with BDFRx go [here](https://old.reddit.com/prefs/apps/) and click "create an app". It's recommended to choose "Installed App" and use "http://localhost:7634" as the redirect url. <!-- markdownlint-disable-line MD034 -->

Once you have your personal client id add it to your [config.cfg](bdfrx/default_config.cfg) at the location in the [configuration](#configuration) section.

## Usage

Expand Down Expand Up @@ -338,6 +345,10 @@ The `config.cfg` is the file that supplies BDFRx with the configuration to use.
- `client_id`
- `scopes`

The following key may be required depending on the type of client id you created.

- `client_secret`

The following keys are optional, and defaults will be used if they cannot be found.

- `backup_log_count`
Expand Down
2 changes: 1 addition & 1 deletion bdfrx/default_config.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[DEFAULT]
client_id = 0vIJGSRQEHgi_r0esNWvjg
client_id =
scopes = identity, history, read, save, mysubreddits
backup_log_count = 3
max_wait_time = 120
Expand Down
5 changes: 3 additions & 2 deletions devscripts/configure.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
if (-not ([string]::IsNullOrEmpty($env:REDDIT_TOKEN)))
if ((-not ([string]::IsNullOrEmpty($env:REDDIT_CLIENT))) -and (-not ([string]::IsNullOrEmpty($env:REDDIT_TOKEN))))
{
Copy-Item .\\bdfrx\\default_config.cfg .\\tests\\test_config.cfg
Write-Output "`nuser_token = $env:REDDIT_TOKEN" >> ./tests/test_config.cfg
(Get-Content -ReadCount 0 .\\tests\\test_config.cfg) -replace "client_id = ", "" | ? {$_.trim() -ne "" } | Set-Content .\\tests\\test_config.cfg
Write-Output "`nclient_id = $env:REDDIT_CLIENT`nuser_token = $env:REDDIT_TOKEN" >> ./tests/test_config.cfg
}
5 changes: 3 additions & 2 deletions devscripts/configure.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/bash

if [ -n "$REDDIT_TOKEN" ]
if [ -n "$REDDIT_CLIENT" ] && [ -n "$REDDIT_TOKEN" ]
then
cp ./bdfrx/default_config.cfg ./tests/test_config.cfg
echo -e "\nuser_token = $REDDIT_TOKEN" >> ./tests/test_config.cfg
sed -i '/client_id = /Id' ./tests/test_config.cfg
echo -e "\nclient_id = $REDDIT_CLIENT\nuser_token = $REDDIT_TOKEN" >> ./tests/test_config.cfg
fi

0 comments on commit a68341f

Please sign in to comment.