Piped login: real username from /feed/rss subtitle (Split-based parse); profiles DELETE needs X-Playlet header + urlencoded id

This commit is contained in:
spaghet committed 2026-11-23 23:51:54 -05:00
1 parent da85f182bb
commit fcd21e72e5
3 files changed
+27 -7

No files matched your search

@@ -383,20 +383,40 @@ namespace Http
return true
end function
' The fork has no /user endpoint, but the authenticated RSS feed names
' the account: its <subtitle> is "Piped's RSS subscription feed for
' <username>.". Read the username from there; fall back to a stable
' uuid label if the shape ever changes. (The profile name is cosmetic.)
function LookupUsername(sessionUuid as string) as string
instance = m.GetInstance()
if StringUtils.IsNullOrEmpty(instance)
return "piped"
end if
res = HttpClient.Get(`${instance}/subscriptions`).Header("Authorization", sessionUuid).Await()
' /feed/rss authenticates via ?authToken= (same contract as /feed).
' The pb nonce keeps this off Piped's ThrottlingCache replay keys.
nonce = CreateObject("roDeviceInfo").GetRandomUUID()
url = `${instance}/feed/rss?authToken=${sessionUuid}&pb=${nonce}`
res = HttpClient.Get(url).Await()
xml = ""
if res.IsSuccess()
' no username in the body; just prove the session works
xml = res.Text()
end if
if not StringUtils.IsNullOrEmpty(xml)
' Split instead of Mid/InStr: substring indexing disagreed with
' the docs on this firmware (both off-by-one directions shipped
' wrong results); Split boundaries are unambiguous.
marker = "feed for "
parts = xml.Split(marker)
if parts.Count() > 1
tail = ValidString(parts[1])
name = ValidString(tail.Split(".")[0])
if name.Len() > 0 and name.Len() < 25
return name
end if
end if
end if
' Piped has no /user endpoint on this fork; the SSO broker's username
' equals the Authentik identity, which we can't see here. Fall back
' to a stable label. (The profile display name is cosmetic.)
return "piped-" + Left(sessionUuid, 8)
end function