Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
## Type of change <!-- (mark with an `X`) --> ``` - [X] Bug fix - [ ] New feature development - [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc) - [ ] Build/deploy pipeline (DevOps) - [ ] Other ``` ## Objective <!--Describe what the purpose of this PR is. For example: what bug you're fixing or what new feature you're adding--> Fix `renew_token` to properly `client.set_tokens(r.access_token, r.refresh_token, r.expires_in)` when logged in via service account access token. When the client's OAuth token expired, a call would be made to the identity server, but the OAuth token was never replaced on the client. The response would map to nothing https://github.com/bitwarden/sdk/blob/a5692418b5836acd3662ce425258d660614bf7f3/crates/bitwarden/src/auth/renew.rs#L87-L90 Then silently error here https://github.com/bitwarden/sdk/blob/4a339a911e6db1583465f69b4c9ff981104ea0ef/crates/bitwarden/src/client/client.rs#L170-L175 This occurs when a client successfully `client.auth().login_access_token` via state, but then shortly after the OAuth token would expire. Subsequent calls would produce HTTP 401. An easier way to produce the error is to log in without state `thread::sleep(Duration::from_secs(4000));` then attempt to make any client call. ## Code changes <!--Explain the changes you've made to each file or major component. This should help the reviewer understand your changes--> <!--Also refer to any related changes or PRs in other repositories--> - **crates/bitwarden/src/auth/renew.rs:** Match to the `IdentityTokenResponse:Payload` returned by the access token request to the identity server. ## Before you submit - Please add **unit tests** where it makes sense to do so
- Loading branch information