get_access_token/
get_access_token.rs

1use tiktok_rust::client;
2
3#[tokio::main]
4async fn main() {
5    // Set the environment variables for client_key and client_secret
6    // For example, in a real application, you would set these in your environment or configuration
7    // env::set_var("TIKTOK_CLIENT_KEY", "your_client_key");
8    // env::set_var("TIKTOK_CLIENT_SECRET", "your_client_secret");
9
10    // Create an instance of the Service
11    let service = client::Service::new();
12
13    // Retrieve the access token
14    match service.get_access_token().await {
15        Ok(token_response) => {
16            println!("Access Token: {}", token_response.access_token);
17            println!("Expires In: {}", token_response.expires_in);
18            println!("Token Type: {}", token_response.token_type);
19        }
20        Err(e) => {
21            eprintln!("Error getting access token: {}", e);
22        }
23    }
24}