#steam #login #openid

steam-auth

Allows you to implement a 'login with steam' feature on your website

4 releases (1 stable)

1.0.0 Jun 18, 2019
0.3.0 Jun 16, 2019
0.2.0 Jun 16, 2019
0.1.0 Jun 15, 2019

#988 in Authentication

MIT license

18KB
223 lines

Docs.rs Build Status

steam-auth

Allows you to implement a 'login with steam' feature on your website.

Usage

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.

Dependencies

~2.7–6.5MB
~144K SLoC