OAuth2 Error 500 UserSignIn No Matching Session #11112

Closed
opened 2025-11-02 09:27:58 -06:00 by GiteaMirror · 2 comments
Owner

Originally created by @nephatrine on GitHub (Jun 27, 2023).

Description

When attempting to log in via Discord or Google OAuth2, it opens up the other site and shows the authorization consent screen. Upon clicking yes, I'm redirected to my callback URI but its a big error 500 with no error message/text or explanation. Looking in the gitea logs, I see these messages:

...eb/routing/logger.go:102:func1() [I] router: completed GET /user/oauth2/discord for [REDACTED]:34454, 307 Temporary Redirect in 2.0ms @ auth/oauth.go:849(auth.SignInOAuth)
...rs/web/auth/oauth.go:939:SignInOAuthCallback() [E] UserSignIn: could not find a matching session for this request
...eb/routing/logger.go:102:func1() [I] router: completed GET /user/oauth2/discord/callback?code=[REDACTED]&state=[REDACTED] for [REDACTED]:34470, 500 Internal Server Error in 2.9ms @ auth/oauth.go:888(auth.SignInOAuthCallback)

I tried to hunt around the open issues for similar things, but #5005 and #5551 don't seem to be my issue. This occurs regardless of DISABLE_REGISTRATION setting and attempts after the first still return the same 500 result.

The Github OAuth2 does work after the first time (which fails with a 500). But nothing I've tried manages to get the other two working. I've checked and double-checked my client id and secret as well as the callback URIs. Any information you might need I'm happy to try providing.

Gitea Version

1.20.0-rc2

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

image

Git Version

2.40.1

Operating System

alpine:latest

How are you running Gitea?

I build it myself and run it in a docker container.

Database

SQLite

Originally created by @nephatrine on GitHub (Jun 27, 2023). ### Description When attempting to log in via Discord or Google OAuth2, it opens up the other site and shows the authorization consent screen. Upon clicking yes, I'm redirected to my callback URI but its a big error 500 with no error message/text or explanation. Looking in the gitea logs, I see these messages: ``` ...eb/routing/logger.go:102:func1() [I] router: completed GET /user/oauth2/discord for [REDACTED]:34454, 307 Temporary Redirect in 2.0ms @ auth/oauth.go:849(auth.SignInOAuth) ...rs/web/auth/oauth.go:939:SignInOAuthCallback() [E] UserSignIn: could not find a matching session for this request ...eb/routing/logger.go:102:func1() [I] router: completed GET /user/oauth2/discord/callback?code=[REDACTED]&state=[REDACTED] for [REDACTED]:34470, 500 Internal Server Error in 2.9ms @ auth/oauth.go:888(auth.SignInOAuthCallback) ``` I tried to hunt around the open issues for similar things, but #5005 and #5551 don't seem to be my issue. This occurs regardless of `DISABLE_REGISTRATION` setting and attempts after the first still return the same 500 result. The Github OAuth2 **does** work after the first time (which fails with a 500). But nothing I've tried manages to get the other two working. I've checked and double-checked my client id and secret as well as the callback URIs. Any information you might need I'm happy to try providing. ### Gitea Version 1.20.0-rc2 ### Can you reproduce the bug on the Gitea demo site? No ### Log Gist _No response_ ### Screenshots ![image](https://github.com/go-gitea/gitea/assets/1461334/a86dd925-491f-4cf8-acfb-d0e4b74d37a7) ### Git Version 2.40.1 ### Operating System alpine:latest ### How are you running Gitea? I build it myself and run it in a docker container. ### Database SQLite
GiteaMirror added the type/bugissue/needs-feedback labels 2025-11-02 09:27:58 -06:00
Author
Owner

@wxiaoguang commented on GitHub (Sep 12, 2023):

Two possibilities:

  1. ROOT_URL doesn't match
  2. #27033
@wxiaoguang commented on GitHub (Sep 12, 2023): Two possibilities: 1. ROOT_URL doesn't match 2. #27033
Author
Owner

@wxiaoguang commented on GitHub (Sep 22, 2023):

Feel free to reopen if there is still a problem.

@wxiaoguang commented on GitHub (Sep 22, 2023): Feel free to reopen if there is still a problem.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#11112