{"record":{"id":"73de0dd9eb3c4fff","repo":"justauth/JustAuth","slug":"url-qq-getuserinfo","errorCode":null,"errorMessage":"不支持获取用户信息 url，请使用小程序内置函数 qq.getUserInfo() 获取用户信息","messagePattern":"不支持获取用户信息 url，请使用小程序内置函数 qq\\.getUserInfo\\(\\) 获取用户信息","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"src/main/java/me/zhyd/oauth/config/AuthDefaultSource.java","lineNumber":1489,"sourceCode":"     */\n    QQ_MINI_PROGRAM {\n        @Override\n        public String authorize() {\n            // 参见 https://q.qq.com/wiki/develop/miniprogram/frame/open_ability/open_userinfo.html 文档\n            throw new UnsupportedOperationException(\"不支持获取授权 url，请使用小程序内置函数 qq.login() 登录获取 code\");\n        }\n\n        @Override\n        public String accessToken() {\n            // 参见 https://q.qq.com/wiki/develop/miniprogram/server/open_port/port_login.html 文档\n            // 获取 openid, unionId , session_key 等字段\n            return \"https://api.q.qq.com/sns/jscode2session\";\n        }\n\n        @Override\n        public String userInfo() {\n            // 参见 https://q.qq.com/wiki/develop/miniprogram/API/open_port/port_userinfo.html 文档\n            throw new UnsupportedOperationException(\"不支持获取用户信息 url，请使用小程序内置函数 qq.getUserInfo() 获取用户信息\");\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return null;\n        }\n    }\n\n}\n","sourceCodeStart":1471,"sourceCodeEnd":1499,"githubUrl":"https://github.com/justauth/JustAuth/blob/694bbf1b010d93404e3bfb4824d90e9ddfaebebb/src/main/java/me/zhyd/oauth/config/AuthDefaultSource.java#L1471-L1499","documentation":"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.","triggerScenarios":"Calling getUserInfo(authToken) on a request for the QQ_MINI_PROGRAM source; a generic token->userInfo pipeline applied uniformly across providers.","commonSituations":"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.","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."],"exampleFix":"// before\nAuthUser user = request.getUserInfo(token); // UnsupportedOperationException\n\n// after\n// client: const profile = qq.getUserInfo({ success: ... }) -> POST /auth/qq-mini {code, nickname, avatar}\n// server identifies user by openid from jscode2session, builds user from the posted profile","handlingStrategy":"validation","validationCode":"if (\"qq_mini_program\".equalsIgnoreCase(sourceName)) {\n    // identity = openid from jscode2session; profile comes from qq.getUserInfo() on the client\n    return userFromJscode2session(code, clientProfile);\n}","typeGuard":"boolean supportsServerUserInfo(AuthSource s) {\n    try { s.userInfo(); return true; }\n    catch (UnsupportedOperationException | AuthException e) { return false; }\n}","tryCatchPattern":"catch (UnsupportedOperationException e) { /* skip getUserInfo; use client-posted profile */ }","preventionTips":["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."],"tags":["justauth","qq","mini-program","unsupported-operation","provider-quirk"],"backgroundTag":null,"analyzedSha":"694bbf1b010d93404e3bfb4824d90e9ddfaebebb","analyzedAt":"2026-08-14T15:16:59.945Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}