mirror of
https://github.com/librespot-org/librespot.git
synced 2024-11-08 16:45:43 +00:00
Ensure a client ID is present
This commit is contained in:
parent
0822af0328
commit
0630586cd6
1 changed files with 6 additions and 1 deletions
|
@ -65,6 +65,11 @@ impl TokenProvider {
|
|||
|
||||
// scopes must be comma-separated
|
||||
pub async fn get_token(&self, scopes: &str) -> Result<Token, Error> {
|
||||
let client_id = self.session().client_id();
|
||||
if client_id.is_empty() {
|
||||
return Err(Error::invalid_argument("Client ID cannot be empty"));
|
||||
}
|
||||
|
||||
if let Some(index) = self.find_token(scopes.split(',').collect()) {
|
||||
let cached_token = self.lock(|inner| inner.tokens[index].clone());
|
||||
if cached_token.is_expired() {
|
||||
|
@ -82,7 +87,7 @@ impl TokenProvider {
|
|||
let query_uri = format!(
|
||||
"hm://keymaster/token/authenticated?scope={}&client_id={}&device_id={}",
|
||||
scopes,
|
||||
self.session().client_id(),
|
||||
client_id,
|
||||
self.session().device_id(),
|
||||
);
|
||||
let request = self.session().mercury().get(query_uri)?;
|
||||
|
|
Loading…
Reference in a new issue