Last.fm auth: mobile sessions and the desktop token flow
- auth.getMobileSession (username + password), auth.getToken and auth.getSession with Last.fm error codes 4/14/15 - /api/auth/ redirects clients' approval links to the web UI's approve page; /api/v1/tokens lets the UI show and approve a token - Tokens expire after an hour, are single use and bound to their app - The legacy md5 authToken form is deliberately unsupported (it needs unsalted password hashes) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e026e56ee3
commit
7622f7433a
8 files changed
+292
-3
No files matched your search
@@ -2,7 +2,7 @@
|
||||
|
||||
import time
|
||||
|
||||
from flask import Blueprint, Response, request
|
||||
from flask import Blueprint, Response, current_app, redirect, request
|
||||
|
||||
from scrobbler import metrics
|
||||
from scrobbler.extensions import db
|
||||
@@ -92,4 +92,12 @@ def dispatch() -> Response:
|
||||
return response
|
||||
|
||||
|
||||
@bp.route("/api/auth/", methods=["GET"], strict_slashes=False)
|
||||
def approve_redirect() -> Response:
|
||||
"""Where Last.fm clients send users to approve a token. Approval happens in the
|
||||
separately hosted web UI, so hand the query string over to its approve page."""
|
||||
query = request.query_string.decode()
|
||||
return redirect(f"{current_app.config['UI_BASE_URL']}/approve.html?{query}", code=302)
|
||||
|
||||
|
||||
from scrobbler.lastfm import methods # noqa: E402,F401 (register handlers)
|
||||
Reference in new issue
Block a user