Crates.io | steam-auth |
lib.rs | steam-auth |
version | 1.0.0 |
source | src |
created_at | 2019-06-15 01:46:39.596377 |
updated_at | 2019-06-18 19:14:25.177242 |
description | Allows you to implement a 'login with steam' feature on your website. |
homepage | |
repository | https://github.com/64/steam-auth |
max_upload_size | |
id | 141254 |
size | 21,772 |
Allows you to implement a 'login with steam' feature on your website.
The easiest way to use this crate is with the reqwest-09x
feature which allows the library to
make HTTP requests on your behalf. Otherwise, you will need to do that manually.
Using the reqwest-09x
feature:
// First, create a redirector
let redirector = Redirector::new("http://localhost:8080", "/callback").unwrap();
// When a user wants to log in with steam, (e.g when they land on the `/login` route),
// redirect them to this URL:
let redirect_url = redirector.url();
// Once they've finished authenticating, they will be returned to `/callback` with some data in
// the query string that needs to be parsed and then verified by sending an HTTP request to the steam
// servers.
match Verifier::make_verify_request(&reqwest::Client::new(), querystring) {
Ok(steam_id) => println!("Successfully logged in user with steam ID 64 {}", steam_id),
Err(e) => eprintln!("There was an error authenticating: {}", e),
}
There is an asynchronous variant: Verifier::make_verify_request_async
which returns a
future. You can also deserialize the data into a SteamLoginData
struct and construct a
Verifier
from that if it is more convenient.
If you don't want to depend on request, you'll need to send the HTTP request yourself. See the
example server and the
Verifier
documentation for more details on how this can be done.
MIT Licensed. Pull requests and contributions welcome.