posit-dev / posit-dev/rsconnect-python

Fall back to device code auth when the localhost browser callback can't complete

Offen
#842 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

enhancement
Vorherrschende Sprache
Python
Sterne
37
Forks
28
Ø Merge
1 T. 3 Std.
Gemergte PRs (30 T.)
7

Beschreibung

Problem

rsconnect login <server> uses an OAuth authorization code flow with a localhost redirect URI. That flow can't complete when the CLI runs on a remote/hosted environment (e.g. Posit Workbench, or any container/cloud session) because the browser that opens is not on the same host as the CLI listener.

Today the user is left with a hung or failed login and no indication of what to do next. The workaround exists — rsconnect login <server> --use-device-code (added in 1.30.0) — but it has to be discovered and typed manually. In practice users, and agentic tools driving the CLI, repeatedly fail the browser flow before finding it.

Requested behavior

Automatically fall back to the device code flow when the authorization code flow can't succeed. Two complementary options:

  1. Detect-and-prefer: when running in an environment where a localhost callback is unlikely to reach the user's browser, default to device code.
  2. Fail-and-retry: if the browser flow times out or the callback never arrives, print a clear message and retry with device code instead of erroring out.

This mirrors what other CLIs do — Claude Code, for example, falls back to device code automatically when its localhost redirect fails, which is why it works in Workbench.

Notes / prior art

  • Posit Publisher works around this on Workbench by using a public-facing callback URL registered in our Connect instances, but that required Workbench-specific code in Publisher to detect the environment. Generalizing that mechanism is a possible longer-term path for first-party tools; third-party tools would still need device code.
  • Device code requires a recent enough Connect, so the fallback should degrade gracefully

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne beim rsconnect-Login-Befehl und verfolge den bestehenden --use-device-code-Pfad parallel zum localhost-Browser-Callback-Flow. Ermittle, wie ein Callback-Fehler oder -Timeout angezeigt wird, und definiere anschließend das Fallback-Verhalten sowie die ordnungsgemäße Behandlung für Connect-Versionen, die device code nicht unterstützen. Als erledigt gilt die Aufgabe, wenn Remote- oder gehostete Sitzungen Benutzer nicht mehr mit einem hängenden Login zurücklassen und einen klaren Weg zur Wiederherstellung bieten.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
authentication, cli
Issue-Typ
Feature
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Aktiv
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
52/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.