Add dotenv to example

This commit is contained in:
Guilherme Werner
2023-12-03 14:10:23 -03:00
parent f309fd834c
commit 67fcf7ce3b
2 changed files with 19 additions and 0 deletions

View File

@ -25,4 +25,5 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0", features = ["raw_value"] }
[dev-dependencies]
dotenv = "0.15.0"
tokio = { version = "1", features = ["full"] }

18
examples/token.rs Normal file
View File

@ -0,0 +1,18 @@
// 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 client = TribufuClient::new(client_id, client_secret).unwrap();
let token = client.get_token().await.unwrap();
println!("{:?}", token)
}