-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmy_did.rs
56 lines (46 loc) · 1.24 KB
/
my_did.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
use anyhow::Result;
use atrium_api::{
agent::{store::MemorySessionStore, AtpAgent},
types::string::Handle,
};
use clap::Parser;
pub const XRPC_HOST: &str = "https://bsky.social";
#[derive(Parser, Debug)]
struct Args {
/// Your bluesky handle
#[arg(long)]
handle: String,
/// An app password. See [app-passwords](https://bsky.app/settings/app-passwords)
#[arg(long)]
app_password: String,
}
#[tokio::main]
async fn main() -> Result<()> {
let args = Args::parse();
let handle = args.handle;
let password = args.app_password;
println!("Logging in...");
let agent = AtpAgent::new(
atrium_xrpc_client::reqwest::ReqwestClient::new(XRPC_HOST),
MemorySessionStore::default(),
);
agent.login(handle.clone(), password).await?;
println!("Fetching your did...");
let publisher_did = agent
.api
.com
.atproto
.identity
.resolve_handle(
atrium_api::com::atproto::identity::resolve_handle::ParametersData {
handle: Handle::new(handle.to_owned()).unwrap(),
}
.into(),
)
.await
.unwrap()
.did
.clone();
println!("Your DID is {publisher_did:?}");
Ok(())
}