Skip to content

Commit

Permalink
Kingosticks change: Obtain spclient access token using login5 instead…
Browse files Browse the repository at this point in the history
… of keymaster (Fixes librespot-org#1179)
  • Loading branch information
Gerrelt committed Dec 1, 2023
1 parent 96e02fd commit ba08273
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions core/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ struct SessionData {
client_brand_name: String,
client_model_name: String,
connection_id: String,
auth_blob: Vec<u8>,
auth_blob: Vec<u8>,
time_delta: i64,
invalid: bool,
user_data: UserData,
Expand Down Expand Up @@ -477,7 +477,7 @@ impl Session {
self.0.data.read().auth_blob.clone()
}

pub fn set_auth_blob(&self, auth_blob: &Vec<u8>,) {
pub fn set_auth_blob(&self, auth_blob: &Vec<u8>) {
self.0.data.write().auth_blob = auth_blob.clone();
}

Expand Down
12 changes: 8 additions & 4 deletions core/src/spclient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use crate::{
},
connect::PutStateRequest,
extended_metadata::BatchedEntityRequest,
login5::{LoginRequest, LoginResponse,},
login5::{LoginRequest, LoginResponse},
},
token::Token,
version::spotify_version,
Expand Down Expand Up @@ -149,7 +149,7 @@ impl SpClient {

Ok(())
}

async fn auth_token_request<M: Message>(&self, message: &M) -> Result<Bytes, Error> {
let client_token = self.client_token().await?;
let body = message.write_to_bytes()?;
Expand Down Expand Up @@ -185,7 +185,8 @@ impl SpClient {

let mut login_request = LoginRequest::new();
login_request.client_info.mut_or_insert_default().client_id = client_id;
login_request.client_info.mut_or_insert_default().device_id = self.session().device_id().to_string();
login_request.client_info.mut_or_insert_default().device_id =
self.session().device_id().to_string();

let stored_credential = login_request.mut_stored_credential();
stored_credential.username = self.session().username().to_string();
Expand Down Expand Up @@ -556,7 +557,10 @@ impl SpClient {
}
headers_mut.insert(
AUTHORIZATION,
HeaderValue::from_str(&format!("{} {}", auth_token.token_type, auth_token.access_token,))?,
HeaderValue::from_str(&format!(
"{} {}",
auth_token.token_type, auth_token.access_token,
))?,
);

let client_token = self.client_token().await?;
Expand Down

0 comments on commit ba08273

Please sign in to comment.