Skip to content

Commit

Permalink
Use project ID specified in config for Pubsub client
Browse files Browse the repository at this point in the history
If the Pubsub client tries to access the pubsub topic or subscription of a
project different from the service account's project, the TokenSource's
project_id (the client's service account's project ID) will be set, so the
topic and subscription of the external project will be set. cannot be
accessed.
Therefore, if the project ID is specified in the config, use that.
  • Loading branch information
h-michael committed Mar 21, 2024
1 parent 96a872d commit ff3c5b3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pubsub/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl ClientConfig {
pub async fn with_auth(mut self) -> Result<Self, google_cloud_auth::error::Error> {
if let Environment::GoogleCloud(_) = self.environment {
let ts = google_cloud_auth::token::DefaultTokenSourceProvider::new(Self::auth_config()).await?;
self.project_id = ts.project_id.clone();
self.project_id = self.project_id.or(ts.project_id.clone());
self.environment = Environment::GoogleCloud(Box::new(ts))
}
Ok(self)
Expand All @@ -70,7 +70,7 @@ impl ClientConfig {
Box::new(credentials),
)
.await?;
self.project_id = ts.project_id.clone();
self.project_id = self.project_id.or(ts.project_id.clone());
self.environment = Environment::GoogleCloud(Box::new(ts))
}
Ok(self)
Expand Down

0 comments on commit ff3c5b3

Please sign in to comment.