justauth/JustAuth · error · UnsupportedOperationException
不支持获取用户信息 url,请使用小程序内置函数 qq.getUserInfo() 获取用户信息
Error message
不支持获取用户信息 url,请使用小程序内置函数 qq.getUserInfo() 获取用户信息
What it means
QQ_MINI_PROGRAM.userInfo() throws UnsupportedOperationException instructing you to use qq.getUserInfo() in the mini-program client. Like its WeChat counterpart, there is no server-side user-info URL; profile data must be gathered client-side and transmitted to your backend in your own payload.
Source
Thrown at src/main/java/me/zhyd/oauth/config/AuthDefaultSource.java:1489
*/
QQ_MINI_PROGRAM {
@Override
public String authorize() {
// 参见 https://q.qq.com/wiki/develop/miniprogram/frame/open_ability/open_userinfo.html 文档
throw new UnsupportedOperationException("不支持获取授权 url,请使用小程序内置函数 qq.login() 登录获取 code");
}
@Override
public String accessToken() {
// 参见 https://q.qq.com/wiki/develop/miniprogram/server/open_port/port_login.html 文档
// 获取 openid, unionId , session_key 等字段
return "https://api.q.qq.com/sns/jscode2session";
}
@Override
public String userInfo() {
// 参见 https://q.qq.com/wiki/develop/miniprogram/API/open_port/port_userinfo.html 文档
throw new UnsupportedOperationException("不支持获取用户信息 url,请使用小程序内置函数 qq.getUserInfo() 获取用户信息");
}
@Override
public Class<? extends AuthDefaultRequest> getTargetClass() {
return null;
}
}
}
View on GitHub (pinned to 694bbf1b01)
Solutions
- Identify the user by openid from the jscode2session response; never call getUserInfo for this source.
- Gather nickname/avatar via qq.getUserInfo() in the client and post them with the code.
- Branch shared login logic by source before the userInfo step; treat UnsupportedOperationException as a first-class case.
Example fix
// before
AuthUser user = request.getUserInfo(token); // UnsupportedOperationException
// after
// client: const profile = qq.getUserInfo({ success: ... }) -> POST /auth/qq-mini {code, nickname, avatar}
// server identifies user by openid from jscode2session, builds user from the posted profile Defensive patterns
Strategy: validation
Validate before calling
if ("qq_mini_program".equalsIgnoreCase(sourceName)) {
// identity = openid from jscode2session; profile comes from qq.getUserInfo() on the client
return userFromJscode2session(code, clientProfile);
} Type guard
boolean supportsServerUserInfo(AuthSource s) {
try { s.userInfo(); return true; }
catch (UnsupportedOperationException | AuthException e) { return false; }
} Try / catch
catch (UnsupportedOperationException e) { /* skip getUserInfo; use client-posted profile */ } Prevention
- Accept client-side profile data in your mini-program login API.
- Branch by source capability before the userInfo step.
- Remember mini-program exceptions are unchecked UnsupportedOperationException, not AuthException.
When it happens
Trigger: Calling getUserInfo(authToken) on a request for the QQ_MINI_PROGRAM source; a generic token->userInfo pipeline applied uniformly across providers.
Common situations: Porting a web OAuth pipeline to QQ mini programs; forgetting that mini-program sources only support accessToken()/jscode2session. The exception is an unchecked UnsupportedOperationException, not AuthException, so it bypasses AuthException-centric handlers.
Related errors
- 不支持获取授权 url,请使用小程序内置函数 qq.login() 登录获取 code
- 不支持获取授权 url,请使用小程序内置函数 wx.login() 登录获取 code
- 不支持获取用户信息 url,请使用小程序内置函数 wx.getUserProfile() 获取用户信息
- 5003
- 5003
AI-assisted analysis of justauth/JustAuth@694bbf1b01 (2026-08-14).
Data as JSON: /api/errors/73de0dd9eb3c4fff.
Report an issue: GitHub.