fix: Use cached credentials if available (#100)
This commit is contained in:
parent
390179c6c9
commit
0262251df9
1 changed files with 6 additions and 2 deletions
|
|
@ -29,11 +29,15 @@ impl Spotify {
|
||||||
market_country_code: Option<CountryCode>,
|
market_country_code: Option<CountryCode>,
|
||||||
) -> Result<Spotify, SpotifyError> {
|
) -> Result<Spotify, SpotifyError> {
|
||||||
// librespot
|
// librespot
|
||||||
let credentials = Credentials::with_password(username, password);
|
let cache = Cache::new(Some(Path::new("credentials_cache")), None, None, None).unwrap();
|
||||||
|
let credentials = match cache.credentials() {
|
||||||
|
Some(creds) => creds,
|
||||||
|
None => Credentials::with_password(username, password),
|
||||||
|
};
|
||||||
let (session, _) = Session::connect(
|
let (session, _) = Session::connect(
|
||||||
SessionConfig::default(),
|
SessionConfig::default(),
|
||||||
credentials,
|
credentials,
|
||||||
Some(Cache::new(Some(Path::new("credentials_cache")), None, None, None).unwrap()),
|
Some(cache),
|
||||||
true,
|
true,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue