Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save shockalotti/cadad64811812c72e87272ff6b93a208 to your computer and use it in GitHub Desktop.

Select an option

Save shockalotti/cadad64811812c72e87272ff6b93a208 to your computer and use it in GitHub Desktop.
#!/usr/bin/env node
/**
* Reddit CLI - Personal posting and browsing tool
*
* Read-only: Uses public JSON API (no auth required)
* Post/Reply: Requires OAuth - run `login` command first
*/
import { createServer } from 'http';
import { readFileSync, writeFileSync, existsSync } from 'fs';
import { homedir } from 'os';
import { join } from 'path';
import { exec } from 'child_process';
const BASE_URL = 'https://www.reddit.com';
const OAUTH_URL = 'https://oauth.reddit.com';
const USER_AGENT = 'script:personal-reddit-cli:v1.0.0';
const TOKEN_FILE = join(homedir(), '.reddit-token.json');
const REDIRECT_URI = 'http://localhost:8080/callback';
const SCOPES = 'read submit edit identity mysubreddits';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment