write_app_credentials_to_env

Function write_app_credentials_to_env 

Source
pub fn write_app_credentials_to_env(
    app_id: &str,
    app_secret: &str,
) -> Result<(), QobuzApiError>
Expand description

Writes app credentials to a .env file.

This function saves Qobuz API credentials (app ID and app secret) to a .env file. If the file already exists, it updates the existing entries; otherwise, it creates a new file. The credentials are stored in environment variables named QOBUZ_APP_ID and QOBUZ_APP_SECRET. This function is useful for caching credentials retrieved from the web player for future use.

§Arguments

  • app_id - The app ID to save
  • app_secret - The app secret to save

§Returns

  • Ok(()) - If the credentials were successfully written to the file
  • Err(Box<dyn Error>) - If there’s an issue reading or writing the .env file

§Examples

use qobuz_api_rust::utils::write_app_credentials_to_env;

let result = write_app_credentials_to_env("my_app_id", "my_app_secret");
match result {
    Ok(()) => println!("Credentials saved successfully"),
    Err(e) => eprintln!("Error saving credentials: {}", e),
}