use anyhow::Result;
use privy_rs::{
PrivyClient,
generated::types::{
CreateUserBody, LinkedAccountCustomJwtInput, LinkedAccountCustomJwtInputType,
LinkedAccountEmailInput, LinkedAccountEmailInputType, LinkedAccountInput,
},
};
use tracing_subscriber::EnvFilter;
#[tokio::main]
async fn main() -> Result<()> {
tracing_subscriber::fmt()
.with_env_filter(
EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info")),
)
.init();
let client = PrivyClient::new_from_env()?;
tracing::info!("initialized privy client from environment");
let user = client
.users()
.create(&CreateUserBody {
linked_accounts: vec![
LinkedAccountInput::EmailInput(LinkedAccountEmailInput {
address: "alex@arlyon.dev".into(),
type_: LinkedAccountEmailInputType::Email,
}),
LinkedAccountInput::CustomJwtInput(LinkedAccountCustomJwtInput {
custom_user_id: "alex@arlyon.dev".try_into().unwrap(),
type_: LinkedAccountCustomJwtInputType::CustomAuth,
}),
],
custom_metadata: None,
wallets: vec![],
})
.await?;
tracing::info!("got new user: {:?}", user);
Ok(())
}