Skip to content

Commit

Permalink
chore: prepare new release(s)
Browse files Browse the repository at this point in the history
  • Loading branch information
BatmanAoD committed Sep 17, 2024
1 parent 8badeec commit 51fe396
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 31 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions qcs-api-client-common/CHANGELOG-py.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.10.2 (2024-09-17)

### Fixes

#### Validate and access token before making an authenticated gRPC request, refreshing the token if it is invalid

## 0.10.1 (2024-09-17)

### Fixes
Expand Down
6 changes: 6 additions & 0 deletions qcs-api-client-common/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.10.2 (2024-09-17)

### Fixes

#### Validate and access token before making an authenticated gRPC request, refreshing the token if it is invalid

## 0.10.1 (2024-09-17)

### Fixes
Expand Down
2 changes: 1 addition & 1 deletion qcs-api-client-common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "qcs-api-client-common"
version = "0.10.1"
version = "0.10.2"
edition = "2021"
license = "Apache-2.0"
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion qcs-api-client-common/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "qcs-api-client-common"
version = "0.10.1"
version = "0.10.2"
description = "Contains core QCS client functionality and middleware implementations."
readme = "README-py.md"
license = { text = "Apache-2.0" }
Expand Down
7 changes: 7 additions & 0 deletions qcs-api-client-common/src/configuration/tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,9 @@ pub trait TokenRefresher: Clone + std::fmt::Debug + Send {
/// refreshing an access token
type Error;

/// Get and validate the current access token, refreshing it if it doesn't exist or is invalid.
async fn validated_access_token(&self) -> Result<String, Self::Error>;

/// Get the current access token, if any
async fn get_access_token(&self) -> Result<Option<String>, Self::Error>;

Expand Down Expand Up @@ -637,6 +640,10 @@ pub trait TokenRefresher: Clone + std::fmt::Debug + Send {
impl TokenRefresher for ClientConfiguration {
type Error = TokenError;

async fn validated_access_token(&self) -> Result<String, Self::Error> {
self.get_bearer_access_token().await
}

async fn refresh_access_token(&self) -> Result<String, Self::Error> {
Ok(self.refresh().await?.access_token()?.to_string())
}
Expand Down
6 changes: 6 additions & 0 deletions qcs-api-client-grpc/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.10.2 (2024-09-17)

### Fixes

#### Validate and access token before making an authenticated gRPC request, refreshing the token if it is invalid

## 0.10.1 (2024-09-17)

### Fixes
Expand Down
4 changes: 2 additions & 2 deletions qcs-api-client-grpc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "qcs-api-client-grpc"
version = "0.10.1"
version = "0.10.2"
edition = "2021"
license = "Apache-2.0"
readme = "README.md"
Expand All @@ -13,7 +13,7 @@ description = "gRPC client for the QCS API"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
qcs-api-client-common = { path = "../qcs-api-client-common", version = "0.10.1" }
qcs-api-client-common = { path = "../qcs-api-client-common", version = "0.10.2" }
http-body = "0.4.5"
hyper = "0.14.23"
hyper-proxy = { version = "0.9.1", default-features = false, features = [
Expand Down
29 changes: 7 additions & 22 deletions qcs-api-client-grpc/src/tonic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,14 @@ where
}
}

let token = match token_refresher
.get_access_token()
let token = token_refresher
.validated_access_token()
.await
.map_err(Error::Refresh)?
{
Some(token) => token,
None => token_refresher
.refresh_access_token()
.await
.map_err(Error::Refresh)?,
};
.map_err(Error::Refresh)?;

let (req, retry_req) = clone_request(req).await;
let resp = make_request(&mut channel, req, token).await?;

match resp.status() {
StatusCode::UNAUTHORIZED | StatusCode::FORBIDDEN => {
// Refresh token and try again
Expand Down Expand Up @@ -213,20 +207,11 @@ where
return service_call(original_req, config, channel).await;
}

// request an access token if one hasn't been requested yet
let token = match config
.get_access_token()
let token = config
.validated_access_token()
.with_current_context()
.await
.map_err(Error::Refresh)?
{
Some(token) => token,
None => config
.refresh_access_token()
.with_current_context()
.await
.map_err(Error::Refresh)?,
};
.map_err(Error::Refresh)?;

let (mut req, mut retry_req) = clone_request(original_req).with_current_context().await;

Expand Down
6 changes: 6 additions & 0 deletions qcs-api-client-openapi/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.11.2 (2024-09-17)

### Fixes

#### Validate and access token before making an authenticated gRPC request, refreshing the token if it is invalid

## 0.11.1 (2024-09-17)

### Fixes
Expand Down
4 changes: 2 additions & 2 deletions qcs-api-client-openapi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "qcs-api-client-openapi"
description = "Auto-generated bindings to the QCS OpenAPI"
version = "0.11.1"
version = "0.11.2"
edition = "2021"
license = "Apache-2.0"
repository = "https://github.com/rigetti/qcs-api-client-rust"
Expand All @@ -10,7 +10,7 @@ keywords = ["API", "QCS", "Rigetti", "quantum"]
categories = ["api-bindings"]

[dependencies]
qcs-api-client-common = { path = "../qcs-api-client-common", version = "0.10.1" }
qcs-api-client-common = { path = "../qcs-api-client-common", version = "0.10.2" }
serde = { version = "1.0.140", features = ["derive"] }
serde_json = "1.0.82"
url = "2.2.2"
Expand Down

0 comments on commit 51fe396

Please sign in to comment.