alibaba/spring-ai-alibaba · error · BizException
Oauth2CallError
Oauth2CallError
Error message
An internal error has occurred during oauth2 call, please try again later.
What it means
Thrown by GitHubOAuth2ServiceImpl.getAccessToken when the HTTP call to GitHub's OAuth token endpoint fails outright (RPC result unsuccessful). The library could not even obtain a valid response from the token URL.
Source
Thrown at spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/base/service/impl/GitHubOAuth2ServiceImpl.java:55
private final OAuth2Config config;
private final HttpClientManager httpClientManager;
public String getAuthorizationUrl() {
return String.format("%s?client_id=%s&redirect_uri=%s&scope=user:email", config.getGithub().getAuthorizeUrl(),
config.getGithub().getClientId(), config.getGithub().getRedirectUri());
}
public String getAccessToken(String code) {
Map<String, Object> params = new HashMap<>();
params.put("client_id", config.getGithub().getClientId());
params.put("client_secret", config.getGithub().getClientSecret());
params.put("code", code);
params.put("redirect_uri", config.getGithub().getRedirectUri());
RpcResult result = httpClientManager.doPostJson(config.getGithub().getTokenUrl(), params);
if (!result.isSuccess()) {
throw new BizException(ErrorCode.OAUTH2_CALL_ERROR.toError(), result.getMessage());
}
Map<String, Object> body = JsonUtils.fromJsonToMap(String.valueOf(result.getResponse()));
if (body.get("error") != null) {
throw new BizException(ErrorCode.OAUTH2_CALL_ERROR.toError(), String.valueOf(result.getResponse()));
}
return (String) body.get("access_token");
}
public Oauth2User getUserInfo(String accessToken) {
Map<String, Object> headers = new HashMap<>();
headers.put("Authorization", "Bearer " + accessToken);
headers.put("Accept", "application/json");
RpcResult result = httpClientManager.doGet(config.getGithub().getUserInfoUrl(), headers, null);
if (!result.isSuccess()) {
throw new BizException(ErrorCode.OAUTH2_CALL_ERROR.toError(), result.getMessage());View on GitHub (pinned to f82da0b50f)
Solutions
- Check the configured github.tokenUrl is correct (https://github.com/login/oauth/access_token) and reachable from the server.
- Verify outbound network/DNS/firewall access to github.com from the service host.
- Retry after confirming GitHub status (https://www.githubstatus.com); the message says to try again later.
Defensive patterns
Strategy: retry
Validate before calling
boolean reachable = pingUrl(oauthConfig.getGithub().getTokenUrl());
if (!reachable) { throw new IllegalStateException("GitHub token endpoint unreachable"); } Try / catch
try {
String token = gitHubOAuth2Service.getAccessToken(code);
} catch (BizException e) {
if ("Oauth2CallError".equals(e.getCode())) {
// surface retry to user; check network egress to github.com
} else { throw e; }
} Prevention
- Verify tokenUrl config points to github.com/login/oauth/access_token
- Allow egress to github.com in firewalls/security groups
- Add bounded retry with backoff for transient network failures
When it happens
Trigger: httpClientManager.doPostJson(config.getGithub().getTokenUrl(), params) returns an unsuccessful RpcResult — network failure, DNS failure, connection timeout, or non-reachable token endpoint.
Common situations: Egress firewall blocking calls to github.com, wrong/placeholder tokenUrl configured, DNS issues in containerized environments, or GitHub returning 5xx/timeouts.
Related errors
- Failed after attempts
- Failed after attempts:
- Network error while fetching URL:
- Fetch attempt {} failed for URL: {}: {}
- Failed to subscribe
AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09).
Data as JSON: /api/errors/b730015fafd0a871.
Report an issue: GitHub.