mirror of
https://github.com/tribufu/sdk-rust
synced 2025-06-16 03:04:19 +00:00
Prototype API (#1)
* Add oauth2 client * Update LICENSE.txt * Create .env.example * Add dotenv to example * Add oauth2 types * Update lib.rs * Update Cargo.toml * Update lib.rs * Add games routes
This commit is contained in:
11
examples/client.rs
Normal file
11
examples/client.rs
Normal file
@ -0,0 +1,11 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved
|
||||
|
||||
use tribufu::*;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
match TribufuClient::new(0, "client_secret") {
|
||||
Ok(client) => println!("client_id: {}", client.id()),
|
||||
Err(e) => println!("error: {:?}", e),
|
||||
}
|
||||
}
|
23
examples/token.rs
Normal file
23
examples/token.rs
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved
|
||||
|
||||
use dotenv::dotenv;
|
||||
use std::env;
|
||||
use tribufu::*;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
dotenv().ok();
|
||||
|
||||
let client_id = env::var("CLIENT_ID").unwrap().parse::<u64>().unwrap();
|
||||
let client_secret = env::var("CLIENT_SECRET").unwrap();
|
||||
|
||||
let mut client = TribufuClient::new(client_id, client_secret).unwrap();
|
||||
|
||||
client.get_token(None).await.unwrap();
|
||||
|
||||
let games = client.get_games().await.unwrap();
|
||||
|
||||
games.iter().for_each(|game| {
|
||||
println!("{}", game.name);
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user