[SM-1189] Fix renew for service account access token logins #702
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Type of change
Objective
Fix
renew_token
to properlyclient.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
Match to the
IdentityTokenResponse:Payload
returned by the access token request to the identity server.Before you submit