-
Notifications
You must be signed in to change notification settings - Fork 185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
svix-cli: Add interactive login #1846
base: main
Are you sure you want to change the base?
Conversation
597c47c
to
12930ec
Compare
Err(e) => { | ||
eprintln!("Failed to get session ID: {}", e); | ||
return Err(anyhow::anyhow!("Failed to get session ID")); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why print to stderr and return an error? Would the error not be printed otherwise?
let response = match client | ||
.post(&poll_url) | ||
.json(&serde_json::json!({ "sessionId": session_id })) | ||
.send() | ||
.await | ||
{ | ||
Ok(resp) => resp, | ||
Err(e) => { | ||
return Err(anyhow::anyhow!( | ||
"Failed to connect to authentication server: {}", | ||
e | ||
)); | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let response = match client | |
.post(&poll_url) | |
.json(&serde_json::json!({ "sessionId": session_id })) | |
.send() | |
.await | |
{ | |
Ok(resp) => resp, | |
Err(e) => { | |
return Err(anyhow::anyhow!( | |
"Failed to connect to authentication server: {}", | |
e | |
)); | |
} | |
}; | |
let response = client | |
.post(&poll_url) | |
.json(&serde_json::json!({ "sessionId": session_id })) | |
.send() | |
.awai | |
.context("Failed to connect to authentication server")?; |
(need to use anyhow::Context
)
match response.json::<AuthTokenOut>().await { | ||
Ok(data) => { | ||
println!("Authentication successful!\n"); | ||
return Ok(data.token); | ||
} | ||
Err(_) => return Err(anyhow::anyhow!("Failed to parse auth token")), | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can also use .context()
here (unless you think we should be hiding the deserialization error?)
Err(_) => "Unknown error".to_string(), | ||
}; | ||
|
||
return Err(anyhow::anyhow!("Authentication failed: {}", error_message)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return Err(anyhow::anyhow!("Authentication failed: {}", error_message)); | |
anyhow::bail!("Authentication failed: {error_message}"); |
Adds a selector when using
svix login
to log in using the dashboard.Demo:
Screen.Recording.2025-03-28.at.3.14.15.PM.mov