Skip to content

Commit

Permalink
auth_code_pkce: add from_token_with_config() constructor
Browse files Browse the repository at this point in the history
This is required to be able to refresh an expired token from the cache
as we need the client ID to refresh the token.

Fix #511
  • Loading branch information
gdesmott committed Dec 29, 2024
1 parent bd35dbc commit e457d7f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/auth_code_pkce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,24 @@ impl AuthCodePkceSpotify {
}
}

/// Build a new [`AuthCodePkceSpotify`] from an already generated token and
/// config. Use this to be able to refresh a token.
#[must_use]
pub fn from_token_with_config(
token: Token,
creds: Credentials,
oauth: OAuth,
config: Config,
) -> Self {
Self {
token: Arc::new(Mutex::new(Some(token))),
creds,
oauth,
config,
..Default::default()
}
}

/// Generate the verifier code and the challenge code.
fn generate_codes(verifier_bytes: usize) -> (String, String) {
log::info!("Generating PKCE codes");
Expand Down

0 comments on commit e457d7f

Please sign in to comment.