4个版本 (1个稳定版)
1.0.0 | 2019年6月18日 |
---|---|
0.3.0 | 2019年6月16日 |
0.2.0 | 2019年6月16日 |
0.1.0 | 2019年6月15日 |
#926 in 认证
每月下载量 53
18KB
223 行
steam-auth
允许您在网站实现“使用Steam登录”功能。
用法
使用此Crate最简单的方法是使用reqwest-09x
功能,该功能允许库代表您发起HTTP请求。否则,您需要手动进行。
使用reqwest-09x
功能
// First, create a redirector
let redirector = Redirector::new("https://127.0.0.1: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),
}
有一个异步版本:Verifier::make_verify_request_async
,它返回一个future。您还可以将数据反序列化为SteamLoginData
结构体,并从该结构体构建一个Verifier
,如果这样做更方便。
如果您不想依赖请求,则需要自己发送HTTP请求。请参阅示例服务器和Verifier
文档以获取更多关于如何执行此操作的信息。
MIT许可。欢迎提交pull请求和贡献。
依赖关系
~3–6.5MB
~158K SLoC