{"record":{"id":"b730015fafd0a871","repo":"alibaba/spring-ai-alibaba","slug":"oauth2callerror","errorCode":"Oauth2CallError","errorMessage":"An internal error has occurred during oauth2 call, please try again later.","messagePattern":"An internal error has occurred during oauth2 call, please try again later\\.","errorType":"error_code","errorClass":"BizException","httpStatus":500,"severity":"error","filePath":"spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/base/service/impl/GitHubOAuth2ServiceImpl.java","lineNumber":55,"sourceCode":"\tprivate final OAuth2Config config;\n\n\tprivate final HttpClientManager httpClientManager;\n\n\tpublic String getAuthorizationUrl() {\n\t\treturn String.format(\"%s?client_id=%s&redirect_uri=%s&scope=user:email\", config.getGithub().getAuthorizeUrl(),\n\t\t\t\tconfig.getGithub().getClientId(), config.getGithub().getRedirectUri());\n\t}\n\n\tpublic String getAccessToken(String code) {\n\t\tMap<String, Object> params = new HashMap<>();\n\t\tparams.put(\"client_id\", config.getGithub().getClientId());\n\t\tparams.put(\"client_secret\", config.getGithub().getClientSecret());\n\t\tparams.put(\"code\", code);\n\t\tparams.put(\"redirect_uri\", config.getGithub().getRedirectUri());\n\n\t\tRpcResult result = httpClientManager.doPostJson(config.getGithub().getTokenUrl(), params);\n\t\tif (!result.isSuccess()) {\n\t\t\tthrow new BizException(ErrorCode.OAUTH2_CALL_ERROR.toError(), result.getMessage());\n\t\t}\n\n\t\tMap<String, Object> body = JsonUtils.fromJsonToMap(String.valueOf(result.getResponse()));\n\t\tif (body.get(\"error\") != null) {\n\t\t\tthrow new BizException(ErrorCode.OAUTH2_CALL_ERROR.toError(), String.valueOf(result.getResponse()));\n\t\t}\n\n\t\treturn (String) body.get(\"access_token\");\n\t}\n\n\tpublic Oauth2User getUserInfo(String accessToken) {\n\t\tMap<String, Object> headers = new HashMap<>();\n\t\theaders.put(\"Authorization\", \"Bearer \" + accessToken);\n\t\theaders.put(\"Accept\", \"application/json\");\n\n\t\tRpcResult result = httpClientManager.doGet(config.getGithub().getUserInfoUrl(), headers, null);\n\t\tif (!result.isSuccess()) {\n\t\t\tthrow new BizException(ErrorCode.OAUTH2_CALL_ERROR.toError(), result.getMessage());","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/base/service/impl/GitHubOAuth2ServiceImpl.java#L37-L73","documentation":"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.","triggerScenarios":"httpClientManager.doPostJson(config.getGithub().getTokenUrl(), params) returns an unsuccessful RpcResult — network failure, DNS failure, connection timeout, or non-reachable token endpoint.","commonSituations":"Egress firewall blocking calls to github.com, wrong/placeholder tokenUrl configured, DNS issues in containerized environments, or GitHub returning 5xx/timeouts.","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."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"boolean reachable = pingUrl(oauthConfig.getGithub().getTokenUrl());\nif (!reachable) { throw new IllegalStateException(\"GitHub token endpoint unreachable\"); }","typeGuard":null,"tryCatchPattern":"try {\n    String token = gitHubOAuth2Service.getAccessToken(code);\n} catch (BizException e) {\n    if (\"Oauth2CallError\".equals(e.getCode())) {\n        // surface retry to user; check network egress to github.com\n    } else { throw e; }\n}","preventionTips":["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"],"tags":["oauth2","github","network","http"],"backgroundTag":"oauth-token-exchange-failed","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}