Required:
- Rust
- reddit account
Rust reddit api wrapper
cargo add roux
async
cargo add futures
cargo add tokio
random strings
cargo add nanoid
parse url querystrings
cargo add querystring
make http requests
cargo add reqwest
cargo add reqwest --features json
cargo add url
base64
cargo add base64
parse cli arguments
cargo add clap
toml parser
cargo add toml
serializer/deserializer
cargo add serde
cargo add serde_derive
If you don't want to type all of that:
cargo add futures tokio nanoid querystring reqwest url base 64 clap roux toml serde serde_derive
cargo add reqwest --features json
cargo add clap --features derive
Login to your reddit account: preferences > apps
To use Reddit’s API, you need a unique and descriptive user agent. The recommended format is <platform>:<app ID>:<version string> (by u/<Reddit username>)
create an app
- put your
client id
andclient secret
along with your user agent, username, and password intoauth.toml
cargo run --release -- --get-auth
If you put in correct credentials in auth.toml
at the root of your project you should also get a valid redirect_url:
Follow the instructions and if you're successful you'll get an access token:
You can now use the access token however you want.
run examples: cargo run --example <example>
run tests:cargo test
The #[cfg(test)] annotation on the tests module tells Rust to compile and run the test code only when you run cargo test, not when you run cargo build
Troubleshooting
- error -
error: could not find system library 'openssl' required by the 'openssl-sys' crate
- solution:
sudo apt install libssl-dev