Skip to main content

bitwarden_core/auth/api/request/
renew_token_request.rs

1use bitwarden_api_api::Configuration;
2use serde::{Deserialize, Serialize};
3
4use crate::auth::{api::response::IdentityTokenResponse, login::LoginError};
5
6#[derive(Serialize, Deserialize, Debug)]
7pub(crate) struct RenewTokenRequest {
8    grant_type: String,
9    refresh_token: String,
10    client_id: String,
11}
12
13impl RenewTokenRequest {
14    pub(crate) fn new(refresh_token: String, client_id: String) -> Self {
15        Self {
16            refresh_token,
17            client_id,
18            grant_type: "refresh_token".to_string(),
19        }
20    }
21
22    pub(crate) async fn send(
23        &self,
24        identity_config: &Configuration,
25    ) -> Result<IdentityTokenResponse, LoginError> {
26        super::send_identity_connect_request(identity_config, &self).await
27    }
28}