| Crates.io | ic-auth-client |
| lib.rs | ic-auth-client |
| version | 0.5.0-beta.0 |
| created_at | 2024-08-24 05:25:33.749259+00 |
| updated_at | 2026-01-19 14:26:29.552695+00 |
| description | A client library for Internet Computer identity authentication services. |
| homepage | |
| repository | https://github.com/perforate-org/ic-auth-client-rs/ |
| max_upload_size | |
| id | 1349821 |
| size | 270,158 |
Port of @icp-sdk/auth for the Rust programming language.
This is a crate for developers who build the frontend of applications for Internet Computer using Rust as the primary language.
ic-agentThe table below shows the compatible versions of ic-auth-client for ic-agent versions.
ic-agent version |
ic-auth-client version |
|---|---|
| 0.45.* | 0.5.* |
| 0.44.* | 0.4.* |
| 0.39.* | 0.3.* |
| 0.37.* or 0.38.* | 0.1.* or 0.2.* |
use ic_auth_client::AuthClient;
To get started with auth client, run
let mut auth_client = AuthClient::builder()
// any configurations
.build()
.await;
The auth_client can log in with
use ic_auth_client::AuthClientLoginOptions;
let options = AuthClientLoginOptions::builder()
.max_time_to_live(7 * 24 * 60 * 60 * 1000_000_000) // 7 days
.on_success(|auth_success| {
// handle success
})
.build();
auth_client.login_with_options(options);
It opens an Internet Identity window, saves your delegation to localStorage, and then sets you up with an identity.
Then, you can use that identity to make authenticated calls using the ic-agent::Agent.
let identity = auth_client.identity();
let agent = Agent::builder()
.with_url(url)
.with_identity(identity)
.build()?;
When using Internet Identity in a native frontend that is not a WebView, there are a few differences.
default-features to false and enable the native feature and one of keyring or pem.ic-auth-client = { version = "*.*.*", default-features = false, features = ["keyring", "native"] }
use ic_auth_client::NativeAuthClient as AuthClient;
// You need a unique service name that will be used by the OS-native secure store
let auth_client = AuthClient::new("your-app")?;
NativeAuthClient::login, which returns a URL to open in the system browser.For step 2, use @perforate/ic-auth-bridge or start from the packaged template in ii-integration/ (or see the Bevy example at examples/bevy/ and copy it into your app or canister frontend. The template already wires the bridge, so you only need to host it and point NativeAuthClient::login at it.
This project is licensed under Apache License, Version 2.0.