Skip to main content
The authentication module provides functionality for logging into Apple accounts using the SRP (Secure Remote Password) protocol and managing authentication tokens.

Account struct

pub struct Account {
    pub anisette: Arc<Mutex<AnisetteData>>,
    pub spd: Option<plist::Dictionary>,
    pub client: Client,
}
Represents an authenticated Apple ID session.

Creating an account

use plume_core::auth::Account;
use omnisette::AnisetteConfiguration;

let config = AnisetteConfiguration::default();

let account = Account::login(
    || Ok(("[email protected]".to_string(), "password".to_string())),
    || Ok("123456".to_string()),  // 2FA code
    config
).await?;

Methods

new
async fn
pub async fn new(config: AnisetteConfiguration) -> Result<Self, Error>
Creates a new account instance with anisette data
login
async fn
pub async fn login(
    appleid_closure: impl Fn() -> Result<(String, String), String>,
    tfa_closure: impl Fn() -> Result<String, String>,
    config: AnisetteConfiguration,
) -> Result<Account, Error>
Authenticates with Apple ID credentials. The closures are called when credentials or 2FA codes are needed.
login_email_pass
async fn
pub async fn login_email_pass(
    &mut self,
    username: &str,
    password: &str,
) -> Result<LoginState, Error>
Attempts to log in with email and password. Returns the current login state.
get_app_token
async fn
pub async fn get_app_token(&self, app: &str) -> Result<AppToken, Error>
Retrieves an app-specific authentication token (e.g., “com.apple.gs.xcode.auth”)
get_name
fn
pub fn get_name(&self) -> (String, String)
Returns (first_name, last_name) from the authenticated session
get_pet
fn
pub fn get_pet(&self) -> Option<String>
Retrieves the PET (Profile Exchange Token) from the session

Login state

pub enum LoginState {
    LoggedIn,
    NeedsDevice2FA,
    Needs2FAVerification,
    NeedsSMS2FA,
    NeedsSMS2FAVerification(VerifyBody),
    NeedsExtraStep(String),
    NeedsLogin,
}
Represents the current state of the authentication flow.

App token

pub struct AppToken {
    pub app_tokens: plist::Dictionary,
    pub auth_token: String,
    pub app: String,
}
Contains authentication tokens for specific Apple services.

Two-factor authentication

Trusted phone numbers

pub struct TrustedPhoneNumber {
    pub number_with_dial_code: String,
    pub last_two_digits: String,
    pub push_mode: String,
    pub id: u32,
}

Authentication extras

pub struct AuthenticationExtras {
    pub trusted_phone_numbers: Vec<TrustedPhoneNumber>,
    pub recovery_url: Option<String>,
    pub cant_use_phone_number_url: Option<String>,
    pub dont_have_access_url: Option<String>,
    pub recovery_web_url: Option<String>,
    pub repair_phone_number_url: Option<String>,
    pub repair_phone_number_web_url: Option<String>,
}

Example: Full authentication flow

use plume_core::auth::Account;
use omnisette::AnisetteConfiguration;

#[tokio::main]
async fn main() -> Result<(), plume_core::Error> {
    let config = AnisetteConfiguration::default();
    
    let account = Account::login(
        || {
            // Prompt user for credentials
            Ok(("[email protected]".to_string(), "password".to_string()))
        },
        || {
            // Prompt user for 2FA code
            Ok("123456".to_string())
        },
        config
    ).await?;
    
    let (first_name, last_name) = account.get_name();
    println!("Logged in as: {} {}", first_name, last_name);
    
    Ok(())
}

Build docs developers (and LLMs) love