Skip to content

Fix OAuth login by prompting for username if needed (fixes #4108)#4129

Open
Nutomic wants to merge 3 commits into
mainfrom
fix-sso-login
Open

Fix OAuth login by prompting for username if needed (fixes #4108)#4129
Nutomic wants to merge 3 commits into
mainfrom
fix-sso-login

Conversation

@Nutomic
Copy link
Copy Markdown
Member

@Nutomic Nutomic commented May 21, 2026

Testing this locally by temporarily changing the "Authorization callback URL" in Github. Correctly prompts for username now, but in the end it returns "https://voyager.lemmy.ml/api/v4/oauth/authenticate". Server logs show this:

lemmy-1  | 2026-05-21T11:20:05.210051Z DEBUG HTTP request{http.method=POST http.route=/api/v4/oauth/authenticate http.flavor=1.1 http.scheme=http http.host=voyager.lemmy.ml http.client_ip=88.13.133.212 http.user_agent=Mozilla/5.0 (X11; Linux x86_64; rv:140.0) Gecko/20100101 Firefox/140.0 http.target=/api/v4/oauth/authenticate otel.name=POST /api/v4/oauth/authenticate otel.kind="server" request_id=4ff4cfc8-2539-453a-8dd0-a3587af9e84e}: actix_web::middleware::logger: Error in response: LemmyError { message: OauthLoginFailed, caller: crates/utils/src/error.rs:278:20, inner: error decoding response body
lemmy-1  |
lemmy-1  | Caused by:
lemmy-1  |     missing field `access_token` at line 1 column 236
lemmy-1  |
lemmy-1  | Stack backtrace:
lemmy-1  |    0: anyhow::error::<impl core::convert::From<E> for anyhow::Error>::from
lemmy-1  |    1: <core::result::Result<T,E> as lemmy_utils::error::LemmyErrorExt<T,E>>::with_lemmy_type::{{closure}}
lemmy-1  |    2: lemmy_api_crud::user::create::authenticate_with_oauth::{{closure}}
lemmy-1  |    3: actix_web::handler::handler_service::{{closure}}::{{closure}}

Comment thread src/shared/components/home/oauth/oauth-callback.tsx
switch (loginRes.err.name) {
case "registration_username_required":
this.setState({ username_required: true });
return;
Copy link
Copy Markdown
Member Author

@Nutomic Nutomic May 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also need to do something similar to ask for registration application if required. Or simply bypass registration application if OAuth is used?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd prefer to keep the registration application required. They're not just used to screen for bots, but also for making sure the user is a good fit for the instance.

@Nutomic
Copy link
Copy Markdown
Member Author

Nutomic commented May 22, 2026

Its working now! You can test by running LEMMY_UI_BACKEND=https://voyager.lemmy.ml pnpm dev and then doing OAuth login with your Github account.

@Nutomic Nutomic marked this pull request as ready for review May 22, 2026 10:57
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.

2 participants