Skip to content

Commit

Permalink
flow-client: Rename with_creds to with_user_access_token to bette…
Browse files Browse the repository at this point in the history
…r represent its behavior
  • Loading branch information
jshearer committed Oct 21, 2024
1 parent bb3e312 commit 43413b4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
4 changes: 2 additions & 2 deletions crates/dekaf/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl Authenticated {
self.client = self
.client
.clone()
.with_creds(Some(access))
.with_user_access_token(Some(access))
.with_fresh_gazette_client();
}

Expand All @@ -98,7 +98,7 @@ impl App {
let client = self
.client_base
.clone()
.with_creds(Some(access.clone()))
.with_user_access_token(Some(access.clone()))
.with_fresh_gazette_client();

let claims = flow_client::client::client_claims(&client)?;
Expand Down
15 changes: 4 additions & 11 deletions crates/flow-client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,9 @@ impl Client {
}
}

pub fn with_creds(self, user_access_token: Option<String>) -> Self {
pub fn with_user_access_token(self, user_access_token: Option<String>) -> Self {
Self {
user_access_token: user_access_token.or(self.user_access_token),
..self
}
}

pub fn as_anonymous(self) -> Self {
Self {
user_access_token: None,
user_access_token,
..self
}
}
Expand Down Expand Up @@ -319,7 +312,7 @@ pub async fn refresh_authorizations(
(Some(access), None) => {
// We have an access token but no refresh token. Create one.
let refresh_token = api_exec::<RefreshToken>(
client.clone().with_creds(Some(access.to_owned())).rpc(
client.clone().with_user_access_token(Some(access.to_owned())).rpc(
"create_refresh_token",
serde_json::json!({"multi_use": true, "valid_for": "90d", "detail": "Created by flowctl"})
.to_string(),
Expand All @@ -346,7 +339,7 @@ pub async fn refresh_authorizations(
let Response {
access_token,
refresh_token: next_refresh_token,
} = api_exec::<Response>(client.clone().as_anonymous().rpc(
} = api_exec::<Response>(client.clone().with_user_access_token(None).rpc(
"generate_access_token",
serde_json::json!({"refresh_token_id": id, "secret": secret}).to_string(),
))
Expand Down
2 changes: 1 addition & 1 deletion crates/flowctl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ impl Cli {
config.user_access_token = Some(access.to_owned());
config.user_refresh_token = Some(refresh.to_owned());

anon_client.with_creds(Some(access))
anon_client.with_user_access_token(Some(access))
}
Err(err) => {
tracing::debug!(?err, "Error refreshing credentials");
Expand Down

0 comments on commit 43413b4

Please sign in to comment.