mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-09 13:07:03 +03:00
manage Spotify credentials
This commit is contained in:
@@ -142,8 +142,8 @@ void LoginBlob::loadJson(const std::string& json) {
|
||||
cJSON* root = cJSON_Parse(json.c_str());
|
||||
this->authType = cJSON_GetObjectItem(root, "authType")->valueint;
|
||||
this->username = cJSON_GetObjectItem(root, "username")->valuestring;
|
||||
std::string authDataObject =
|
||||
cJSON_GetObjectItem(root, "authData")->valuestring;
|
||||
std::string authDataObject = cJSON_GetObjectItem(root, "authData")->valuestring;
|
||||
this->authData = crypto->base64Decode(authDataObject);
|
||||
cJSON_Delete(root);
|
||||
#else
|
||||
auto root = nlohmann::json::parse(json);
|
||||
|
||||
@@ -17,6 +17,10 @@
|
||||
#include "PlainConnection.h" // for PlainConnection, timeoutCallback
|
||||
#include "ShannonConnection.h" // for ShannonConnection
|
||||
|
||||
#include "pb_decode.h"
|
||||
#include "NanoPBHelper.h" // for pbPutString, pbEncode, pbDecode
|
||||
#include "protobuf/authentication.pb.h"
|
||||
|
||||
using random_bytes_engine =
|
||||
std::independent_bits_engine<std::default_random_engine, CHAR_BIT, uint8_t>;
|
||||
|
||||
@@ -79,9 +83,13 @@ std::vector<uint8_t> Session::authenticate(std::shared_ptr<LoginBlob> blob) {
|
||||
auto packet = this->shanConn->recvPacket();
|
||||
switch (packet.command) {
|
||||
case AUTH_SUCCESSFUL_COMMAND: {
|
||||
APWelcome welcome;
|
||||
CSPOT_LOG(debug, "Authorization successful");
|
||||
pbDecode(welcome, APWelcome_fields, packet.data);
|
||||
return std::vector<uint8_t>(
|
||||
{0x1}); // TODO: return actual reusable credentaials to be stored somewhere
|
||||
welcome.reusable_auth_credentials.bytes,
|
||||
welcome.reusable_auth_credentials.bytes + welcome.reusable_auth_credentials.size
|
||||
);
|
||||
break;
|
||||
}
|
||||
case AUTH_DECLINED_COMMAND: {
|
||||
|
||||
Reference in New Issue
Block a user