1 unstable release
0.1.0 | Jun 28, 2022 |
---|
#63 in #discord-api
17KB
288 lines
discord-qr-auth
discord-qr-auth is a Rust library that lets you authenticate users using QR codes.
Example
use qrcode::render::unicode;
use discord_qr_auth::core::websocket::Client;
#[tokio::main]
async fn main() {
let mut ws = Client::default();
ws.connect().await.unwrap();
let qr = ws.get_code().await.unwrap();
let image = qr
.render::<unicode::Dense1x2>()
.dark_color(unicode::Dense1x2::Light)
.light_color(unicode::Dense1x2::Dark)
.build();
println!("{}\nScan this QR code in the Discord app on your phone.", image);
let user = ws.get_user().await.unwrap();
println!("User {} scanned QR code!", user.username);
let token = ws.get_token().await.unwrap();
println!("User accepted log-in. Token: {}", token);
}
lib.rs
:
discord-qr-auth
is a crate that allows you to authenticate a user with Discord using a QR code.
View the examples to see how to use this crate.
Installation
Add the following to your Cargo.toml
file:
[dependencies]
discord-qr-auth = "0.1.0"
Dependencies
~13–25MB
~380K SLoC