theonedev/onedev · error · AuthenticationException

Unable to get guilds info

Error message

Unable to get guilds info

What it means

Thrown by DiscordConnector.processTokenResponse when the API request to list the user's Discord guilds (GET users/@me/guilds) does not return an OK response, so server membership cannot be verified. The connector cannot confirm the user belongs to the configured Discord server and aborts authentication.

Source

Thrown at server-plugin/server-plugin-sso-discord/src/main/java/io/onedev/server/plugin/sso/discord/DiscordConnector.java:134

				
				String subject = (String) userObject.get("id");
				String userName = (String) userObject.get("username");
				String email = StringUtils.trimToNull((String) userObject.get("email"));
				Boolean verified = (Boolean) userObject.get("verified");
				if (verified != null && !verified)
					email = null;
				
				if (bCheckGuilds) {
					UserGuildsResponse guildsResponse = apiRequest.getUserGuilds(accessTokenResponse);
					
					if (guildsResponse.isOK()) {
						JSONObject serverInfo = guildsResponse.getServerInfo(getServerId());
						
						if (serverInfo == null) {
							throw new AuthenticationException(_T("You are not member of discord server"));
						}
					} else {
						throw new AuthenticationException(_T("Unable to get guilds info"));
					}
				}

				return new SsoAuthenticated(subject, userName, email, null, null, null);
			} else {
				String errorMessage = userInfoResponse.getMessage();
				if (errorMessage != null) {
					throw new AuthenticationException(errorMessage);
				}
				
				throw new AuthenticationException(userInfoResponse.getContent());
			}
		} catch (IOException | JSONException e) {
			throw new RuntimeException(e);
		}
	}
	
	private String getScopes() {

View on GitHub (pinned to d44925c47c)

Solutions

  1. Add the 'guilds' (and/or 'guilds.read') scope to the Discord SSO connector's scope configuration.
  2. Retry the login later or check Discord status page if Discord API is rate-limiting or down.
  3. Verify the OneDev server can reach https://discord.com/api (check proxies/firewall).
  4. Re-authenticate from scratch so a fresh, valid access token is used.

Example fix

// before
scopes: ["identify", "email"]
// after
scopes: ["identify", "email", "guilds"]
Defensive patterns

Strategy: retry

Try / catch

try {
    auth = connector.handleAuthResponse(...);
} catch (AuthenticationException e) {
    if (e.getMessage().contains("Unable to get guilds info")) {
        // check Discord API status/network, then retry login after a delay
    }
}

Prevention

When it happens

Trigger: After exchanging the token, apiRequest.getUserGuilds(accessTokenResponse) receives a non-2xx response from Discord — commonly caused by the access token lacking the 'guilds' scope, an expired/invalid token, or Discord API downtime/rate limiting.

Common situations: Connector's OAuth scopes missing 'guilds' or 'guilds.read'; Discord API incident or rate limit (429) at login time; network/proxy blocking api.discord.com from the OneDev server; token already revoked by user.

Related errors


AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06). Data as JSON: /api/errors/0f943ed201cde1f1. Report an issue: GitHub.