- Return a distinct post-auth warning page when Spotify OAuth completes but the client still does not report an authenticated session.
- Send the completion signal back to the opener so the settings UI can refresh and show the warning state immediately.
- Keep the standalone callback server and the main Flask callback path aligned on the same result-page helper.
add_activity_item("","Spotify Auth Complete",f"Profile {profile_id_from_state} authenticated with Spotify","Now")
return_spotify_auth_result_page("Your personal Spotify account is now connected. You can close this window.",authenticated=True)
ifprofile_client:
profile_client._invalidate_auth_cache()
_status_cache_timestamps['spotify']=0
add_activity_item("","Spotify Auth Warning",f"Profile {profile_id_from_state} completed OAuth but Spotify did not confirm an authenticated session","Now")
return_spotify_auth_result_page(
"Spotify authorization completed, but SoulSync could not confirm an authenticated Spotify session for this profile. You can close this window and try Authenticate again.",
authenticated=False,
)
else:
raiseException("Failed to exchange authorization code for access token")
add_activity_item("","Spotify Auth Complete","Successfully authenticated with Spotify","Now")
return_spotify_auth_success_page("You can close this window.")
return_spotify_auth_result_page("You can close this window.",authenticated=True)
else:
raiseException("Token exchange succeeded but authentication validation failed")
logger.warning("Spotify OAuth token exchange succeeded but authentication validation failed")
spotify_client._invalidate_auth_cache()
_status_cache_timestamps['spotify']=0
add_activity_item("","Spotify Auth Warning","OAuth completed, but Spotify did not confirm an authenticated session","Now")
return_spotify_auth_result_page(
"Spotify authorization completed, but SoulSync could not confirm an authenticated Spotify session. You can close this window and try Authenticate again.",
authenticated=False,
)
else:
raiseException("Failed to exchange authorization code for access token")
self.wfile.write(_spotify_auth_success_page("You can close this window.").encode("utf-8"))
self.wfile.write(_spotify_auth_result_page("You can close this window.",authenticated=True).encode("utf-8"))
else:
raiseException("Token exchange succeeded but authentication validation failed")
_oauth_logger.warning("Spotify token exchange succeeded but authentication validation failed")
spotify_client._invalidate_auth_cache()
_status_cache_timestamps['spotify']=0
add_activity_item("","Spotify Auth Warning","OAuth completed, but Spotify did not confirm an authenticated session","Now")
self.send_response(200)
self.send_header('Content-type','text/html')
self.end_headers()
self.wfile.write(_spotify_auth_result_page(
"Spotify authorization completed, but SoulSync could not confirm an authenticated Spotify session. You can close this window and try Authenticate again.",
authenticated=False,
).encode("utf-8"))
else:
raiseException("Failed to exchange authorization code for access token")