reddit-cli

authentication

configure app-only oauth for the live reddit api.

the live api uses the oauth client_credentials grant. use a reddit application with data api access. you can use the archive without credentials. see sources for the data api shutdown dates.

save credentials

reddit auth login --client-id YOUR_CLIENT_ID
reddit auth status

enter the secret at the hidden prompt. for scripted login, pass --client-secret-stdin and supply the secret on standard input. use --user-agent to set a custom user agent. login writes the config, requests a token to verify access, and reports ok, scope, and expires_in.

use environment variables

environment variablefallback in config.toml
REDDIT_CLIENT_ID[auth] client_id
REDDIT_CLIENT_SECRET[auth] client_secret
REDDIT_USER_AGENT[auth] user_agent

the cli resolves each field separately. environment values take precedence over the config file. empty values and unresolved placeholders count as unset. the default user agent follows <os>:reddit-cli:<version> (+https://github.com/Microck/reddit-cli).

reddit auth status reports each field's origin (env, config, or unset), the resolved source, whether the cached token is valid, and the last rate-limit state. it keeps credential values private.

local files and logout

config.toml lives in the platform config directory under reddit-cli/. the cached token lives in token.json under the platform data directory. see local store for the directory overrides. on unix, the cli uses mode 0600 for these files and 0700 for their directories. it treats tokens as expired 60 seconds early and refreshes the token once if a live request returns http 401.

reddit auth logout

logout removes the saved credentials and cached token. if you set credentials through the environment, clear those variables in your shell too.

On this page