我的问题是我可以输入不正确的登录凭据,但我仍然可以成功登录。我的代码看起来像这样。即使我只是敲击键盘输入我的用户名和密码,它仍然告诉我我已经成功登录。
void CreateSession()
{
memset(&config, 0, sizeof(config));
config.api_version = SPOTIFY_API_VERSION;
config.cache_location = "tmp";
config.settings_location = "tmp";
config.application_key = g_appkey;
config.application_key_size = g_appkey_size;
config.user_agent = "SpotifyTest";
error = sp_session_create(&config, &session);
qDebug() << "1";
if (SP_ERROR_OK != error)
{
qDebug() << "failed to create session: " << sp_error_message(error);
return;
}
}
void Login(char* username, char* password)
{
char *blob = NULL;
if(session == NULL)
{
CreateSession();
qDebug() << "Session Created";
}
error = sp_session_login(session, username, password, 1, blob);
if (SP_ERROR_OK != error)
{
qDebug() << "failed to log in to Spotify: " << sp_error_message(error);
sp_session_release(session);
}
else
{
qDebug() << "Successful Login";
QString user_name = sp_session_user_name(session);
qDebug() << user_name;
}
}