Crates.io | discord-qr-auth |
lib.rs | discord-qr-auth |
version | 0.1.0 |
source | src |
created_at | 2022-06-28 12:45:09.011527 |
updated_at | 2022-06-28 12:45:09.011527 |
description | A Rust library to authenticate with Discord using QR codes. |
homepage | https://github.com/safecord/discord-qr-auth |
repository | https://github.com/safecord/discord-qr-auth.git |
max_upload_size | |
id | 614812 |
size | 17,633 |
discord-qr-auth is a Rust library that lets you authenticate users using QR codes.
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);
}