Skip to content

Sign in manually when the browser doesn't hand the sign-in back - #24

Open
marshmallow-mia wants to merge 11 commits into
Villagers654:mainfrom
marshmallow-mia:auth-copy-link
Open

marshmallow-mia wants to merge 11 commits into
Villagers654:mainfrom
marshmallow-mia:auth-copy-link

Conversation

@marshmallow-mia

Copy link
Copy Markdown
Contributor

What this fixes

Sign-in only worked through the browser RiftLift detected and launched, and only if the browser then passed Meta's
oculus:// address back. When no default browser was found, the browser failed to start, or the oculus:// address
never reached RiftLift, sign-in stopped or waited forever. Someone signed in to Meta in another browser had no way to use
it. On main, a missing or failing browser leaves an error and "Try again", with the explanation cut off:

Main without a browser

One quiet "Sign in manually" option. Under the normal flow there's now a "Sign in manually" button. It opens two
steps:

  1. Open this link in any browser and sign in to Meta (with Copy link).
  2. When Meta's Continue button seems to do nothing, paste the address that starts with oculus://.

The section opens by itself only when RiftLift couldn't start a browser; otherwise the dialog looks as it did.

No browser found

Adding another account works the same way: the manual steps open under the signed-in accounts, and cancelling goes
back to the account list with every account still signed in.

Pasting is forgiving and safe. A whole browser console message can be pasted; RiftLift picks the oculus://
address out of it. Anything without one gets a plain message instead of a protocol error. A pasted address takes the
same path as the URL handler's: the waiting sign-in checks it against its own request before asking Meta for the
session. An address from an earlier sign-in is refused right away with a hint, and the sign-in keeps waiting.

Wrong paste

A guide: docs/MANUAL_SIGN_IN.md. Normally the browser asks to open "RiftLift Meta Login" and sign-in finishes by
itself. When nothing receives the address, Firefox's Web Console shows it after Continue (Chrome and Chromium show it
nowhere). The guide walks through that with screenshots on a stand-in page with example values. "How do I find that
address?" in the dialog and the README's troubleshooting list link to it. The link also puts the guide's address on the
clipboard and shows it in the dialog: Qt hands the link to the desktop portal, which reports success even when nothing
opens it (on KDE without a handler for https, the portal answered "No entry for x-scheme-handler/https" and success), so
a "did it open?" check can't be trusted.

The dialog fits its text. A top-level Qt dialog doesn't resize for wrapped labels, so on main the explanation is
cut off at "…open RiftLift when" (32 px high where 51 are needed), and a one-line status gets 33 px for a 15 px line.
Each wrapped label now gets exactly the height its text needs at the dialog's width,
and the dialog sizes to its content: larger when the manual section opens, smaller again when it closes, with no gap
around a one-line status and without Qt's negative-size warnings. The labels fit again whenever the dialog's width
changes; narrowed to its minimum, the French explanation was cut off before.

Testing

On 0.11.1.2

Nothing is left unverified on 0.11.1.2.

Live on Windows 10 with a real Meta account (the fork CI's installer of all branches merged, Brave as the default
browser):

  • Through the URL handler: Sign In registers oculus:// for RiftLift and opens Brave. After the login and
    Continue, Brave hands the address to RiftLift, the dialog closes, and the account works against the store.
  • Manually: signed out, Sign In again, then the oculus:// handler removed so nothing can open the address.
    • Copy link, opened in a new Brave tab.
    • After Continue, the oculus:// address was copied from Brave's console (F12).
    • Pasted into the dialog, it signs in, and the store accepts the new login.

Live on Linux with a real Meta account (the CI AppImage of all branches merged):

  • The manual sign-in:
    • The link opened in a Firefox profile without the oculus:// handler.
    • After Continue, the Web Console filtered for "oculus" shows "Prevented navigation to “oculus://…” due to an unknown
      protocol."
    • Copy Message, paste the whole message, Sign in: the account is signed in, and the owned list loads.
  • A second account: pasting the address already used for the first sign-in is refused at once ("That address is
    from an earlier sign-in…"), the attempt keeps waiting, and Cancel goes back to the account list.
  • No browser:
    • "No default browser was found. Sign in manually below." with the steps open.
    • "How do I find that address?" puts the guide's address on the clipboard and shows it.
    • Before the last commit, that click did nothing here (see above).

The dialog's new parts sit on upstream's multi-account dialog: starting a sign-in still only prepares it
(prepare_login, no sign-out), cancel keeps the accounts, and the browser is stopped through _stop_browser() as
upstream does on Windows. A browser that exits with an error only clears the process, so the Chromium window someone
may be signing in with stays open.

  • tests/test_auth_link.py now checks the token through the account list and uses cancel_login();
    test_auth_dialog_reports_browser_launch_failure expects the sign-in to keep waiting.
  • Screenshots re-taken on Linux (KDE Plasma) in the current theme: normal flow, manual steps, no browser, wrong paste,
    an account signed in, adding a second one manually, and back to the list after cancelling.
  • The full suite on Linux (Python 3.10 + PySide6 6.7, 3.12 + 6.11 and 3.12 + 6.12) for every commit, and on macOS.
  • Fork CI on the ported branch: the CI and Windows workflows pass, Python and native jobs alike.
  • New since the last base: test_the_guide_address_is_copied_even_when_opening_it_reports_success, which fails
    before the last commit, with and without a browser.

Earlier, on 7289ef6

  • New tests/test_auth_link.py (19 tests): section collapsed or opened by itself depending on the browser, copy link,
    paste finishes the sign-in, wrong paste refused, whole console messages accepted, guide link, reset, no clipped text,
    no extra space around wrapped text, shrinking after close, no Qt size warnings, an address from an earlier sign-in,
    the guide without a browser, text after narrowing the dialog.
  • Live on Linux with a real Meta account:
    • The normal flow with the registered handler signs in by itself.
    • Manual: the copied link opened in a Firefox without the handler, the Web Console filtered for "oculus", the whole
      message copied and pasted, signed in.
    • No browser found, and a browser that fails to start: the manual section opens by itself, and the sign-in still
      finishes with a pasted message.
    • Copy link puts the sign-in URL on the clipboard; an https address is refused with "That isn't the address from
      Meta"; the dialog grows from 280 to 462 px with the manual section and shrinks back to 242 px on cancel.
    • The same two browser cases on main: only "Try again", no link and no input, with clipped labels.
  • pytest, ruff and the installer step on Linux: same results as main for every commit, plus the new tests.

The sign-in dialog only worked through the browser RiftLift detected and
launched. When no default browser could be found or the browser failed to
start, sign-in stopped with an error, and
someone who signs in to Meta in another browser had no way to use it.

As soon as Meta's sign-in link exists, the dialog shows it in a read-only
field with a Copy link button, whether or not a browser opened. A missing
default browser or a browser that fails to start no longer ends the
sign-in: the dialog says so and keeps waiting for the callback.

The dialog also grows for its wrapped text now. A top-level dialog doesn't
do that by itself, so the explanation was cut off already, and the link
section would have been squashed.
Meta finishes the sign-in by sending the browser to an oculus:// address,
which only reaches RiftLift where it registered a URL handler (Linux and
Windows). Where that doesn't happen, such as when the handler couldn't be
registered or the browser ignores it, the sign-in waited forever.

Under the sign-in link, a "Browser didn't come back to RiftLift?" button
reveals a field for that address. It is hidden until asked for. A pasted
address goes through the same path as the URL handler's: only oculus://
is accepted, and the waiting sign-in verifies it against its own request
before asking Meta for the session.
An empty label's heightForWidth is -1, which Qt refuses as a minimum height
and logs as a warning every time the dialog fits its text.
The fallback read as an afterthought: a sign-in link always on screen and a
"Browser didn't come back to RiftLift?" toggle for pasting. Everything
manual now sits behind one quiet "Sign in manually" button, as two
numbered steps: open this link in any browser, then paste the oculus://
address Meta's Continue button tries to open. The section opens by itself
only when RiftLift couldn't start a browser.

Pasting a whole browser console message works: RiftLift picks the
oculus:// address out of it. A paste without one gets a plain message
instead of the protocol error.

docs/MANUAL_SIGN_IN.md covers both cases. Normally the browser asks to
open RiftLift Meta Login and the sign-in finishes by itself. When nothing
receives the address, Firefox's Web Console shows it after Continue
(Chrome and Chromium show it nowhere), so the guide walks through that,
with screenshots on a stand-in page with example values. "How do I find
that address?" in the dialog and the README's troubleshooting list link
to it.
The dialog only ever grew to fit its text. After closing the manual
sign-in (Cancel sign-in, or an error) it stayed at its tall size and the
remaining text spread out with large gaps. It now takes the height its
content needs, smaller as well as larger.
The Web Console often shows unrelated page warnings too, and copying the
wrong line fails the sign-in. Typing oculus into its filter leaves only
the message to copy.
Each wrapped label only got a minimum height. The dialog's size came from
Qt's estimate for wrapping labels, which assumes several lines for longer
text, and the layout handed the surplus to the status line: with "Could not
open the browser for Meta sign-in." it sat in a 51 px gap for one 15 px line.
Labels are now as tall as their text at the dialog's width.
A pasted address was only checked against the waiting sign-in once Meta's
session was completed. One from an earlier attempt, for example an old
console message, then ended the attempt with "Meta returned an invalid
login callback" and hid the manual section, so signing in had to start
over in the browser. The paste is now checked against the request first;
an earlier address gets a hint, and the sign-in keeps waiting.
The guide link is for the case where RiftLift found no working browser,
but it only asked the desktop to open the page and ignored the result.
With no browser, the click did nothing. The address now goes to the
clipboard, and the dialog says so.
Each wrapped label gets the height its text needs at the dialog's width,
but only when the dialog's content changed. Narrowed to its minimum width
after an error, the French explanation needed 68 px and kept 51, cutting
off its last line. The labels are now fitted again on every width change.
The address only went to the clipboard when Qt reported that the page
couldn't be opened. Qt hands the link to the desktop portal, which reports
success even when nothing on the system opens https links: on KDE with
xdg-desktop-portal 1.22 it answered "No entry for x-scheme-handler/https"
internally and success to RiftLift. The click then did nothing, with or
without a browser. The address now always goes to the clipboard, and the
dialog says so.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant