Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect OAuth2 ID/Secret leads 500 / incorrect error message #23936

Closed
wxiaoguang opened this issue Apr 5, 2023 · 0 comments · Fixed by #25261
Closed

Incorrect OAuth2 ID/Secret leads 500 / incorrect error message #23936

wxiaoguang opened this issue Apr 5, 2023 · 0 comments · Fixed by #25261
Labels

Comments

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Apr 5, 2023

Description

Many users reported this problem: when they try to use OAuth2 as auth source, they see 500 errors, and an unclear error message in log:

/auth/oauth.go:920:SignInOAuthCallback() [E] [642b21e7-2] UserSignIn: oauth2: server response missing access_token

The problem is that:

  1. If the user double-click and copy the secret from GitHub app page, there will be an extra space in the Client Secret field.
  2. The incorrect Client Secret makes the auth failed. GitHub returns clear message
  3. However, the goth package doesn't respect the error message, it only returns an error "server response missing access_token"
  4. If the callback URL is incorrect, some 500 error might also happen.

To fix the problem:

  1. Trim spaces.
  2. Fix goth package, make it respect the returned error message.
  3. Make Gitea show more details if goth returns unclear messages, at least it helps users.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant