fix callback server not returning anything to the browser, implementing a way to change the content of the success page

This commit is contained in:
Matteo Fuso
2025-11-09 17:54:27 +01:00
parent 8760279c64
commit ccf625c5c5
3 changed files with 30 additions and 8 deletions

View File

@@ -76,18 +76,22 @@ session = Session.Builder() \
.create()
```
#### With auth url callback
#### With auth url callback and changing the content of the success page
```python
from librespot.core import Session
import webbrowser
# This will pass the auth url to the method
def auth_url_callback(url):
print(url)
webbrowser.open(url)
# This is the response sent to the browser once the flow has been completed successfully
success_page = "<html><body><h1>Login Successful</h1><p>You can close this window now.</p><script>setTimeout(() => {window.close()}, 100);</script></body></html>"
session = Session.Builder() \
.oauth(auth_url_callback) \
.oauth(auth_url_callback, success_page) \
.create()
```