{"record":{"id":"197f9e0f4df80c4d","repo":"justauth/JustAuth","slug":"5001-197f9e","errorCode":"5001","errorMessage":"Not Implemented","messagePattern":"Not Implemented","errorType":"exception","errorClass":"AuthException","httpStatus":null,"severity":"error","filePath":"src/main/java/me/zhyd/oauth/request/AuthRequest.java","lineNumber":34,"sourceCode":" * {@link AuthRequest#revoke(AuthToken)}\n * {@link AuthRequest#refresh(AuthToken)}\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.8\n */\npublic interface AuthRequest {\n\n    /**\n     * 返回授权url，可自行跳转页面\n     * <p>\n     * 不建议使用该方式获取授权地址，不带{@code state}的授权地址，容易受到csrf攻击。\n     * 建议使用{@link AuthDefaultRequest#authorize(String)}方法生成授权地址，在回调方法中对{@code state}进行校验\n     *\n     * @return 返回授权地址\n     */\n    @Deprecated\n    default String authorize() {\n        throw new AuthException(AuthResponseStatus.NOT_IMPLEMENTED);\n    }\n\n    /**\n     * 返回带{@code state}参数的授权url，授权回调时会带上这个{@code state}\n     *\n     * @param state state 验证授权流程的参数，可以防止csrf\n     * @return 返回授权地址\n     */\n    default String authorize(String state) {\n        throw new AuthException(AuthResponseStatus.NOT_IMPLEMENTED);\n    }\n\n    /**\n     * 获取access token\n     *\n     * @param authCallback 授权成功后的回调参数\n     * @return token\n     * @see AuthDefaultRequest#authorize()","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/justauth/JustAuth/blob/694bbf1b010d93404e3bfb4824d90e9ddfaebebb/src/main/java/me/zhyd/oauth/request/AuthRequest.java#L16-L52","documentation":"AuthRequest is the top-level JustAuth interface. authorize(String state) is a default method that unconditionally throws AuthException with AuthResponseStatus.NOT_IMPLEMENTED (code 5001). The library expects each concrete request class to override it; the default exists only so hand-written implementations compile. This specific variant is the stateful authorize used to build the redirect URL for the OAuth flow.","triggerScenarios":"Calling authRequest.authorize(\"someState\") on an implementation that does not override authorize(String) — e.g. a custom class that implements AuthRequest directly but only implements getAccessToken/getUserInfo, or a mock/stub passed in tests.","commonSituations":"Writing a custom AuthRequest for an unsupported provider and forgetting the authorize override; unit tests with anonymous AuthRequest implementations; refactoring away from AuthDefaultRequest.","solutions":["Override `String authorize(String state)` in your custom AuthRequest implementation and return the provider's authorize URL.","Extend AuthDefaultRequest instead of implementing AuthRequest from scratch — it already implements authorize(state) via the source definition.","If you only need the URL for a built-in provider, use AuthRequestBuilder.build() (JustAuth.request(...)) so a fully implemented class is returned."],"exampleFix":"// before\nclass MyRequest implements AuthRequest {\n    public AuthToken getAccessToken(AuthCallback c) { ... }\n    public AuthUser getUserInfo(AuthToken t) { ... }\n}\nString url = new MyRequest(...).authorize(\"state\"); // AuthException 5001\n\n// after\nclass MyRequest extends AuthDefaultRequest {\n    public MyRequest(AuthConfig c) { super(c, AuthDefaultSource.MY_PROVIDER); }\n    // authorize(String) inherited and functional\n}\nString url = new MyRequest(config).authorize(\"state\");","handlingStrategy":"validation","validationCode":"// before building URLs, ensure the implementation really supports authorize\nif (request instanceof AuthDefaultRequest) {\n    String url = request.authorize(state);\n} else {\n    throw new IllegalStateException(\"AuthRequest implementation must extend AuthDefaultRequest or override authorize(String)\");\n}","typeGuard":"boolean supportsAuthorize(AuthRequest r) {\n    return r instanceof AuthDefaultRequest\n        || Arrays.stream(r.getClass().getMethods())\n               .anyMatch(m -> m.getName().equals(\"authorize\") && !m.isDefault() && m.getDeclaringClass() != AuthRequest.class);\n}","tryCatchPattern":"try { url = request.authorize(state); }\ncatch (AuthException e) {\n    if (e.getCode() == 5001) throw new IllegalStateException(\"authorize not implemented by \" + request.getClass().getName(), e);\n    throw e;\n}","preventionTips":["Always extend AuthDefaultRequest for custom providers instead of implementing AuthRequest directly.","Add an architecture test (ArchUnit) that custom AuthRequest classes extend AuthDefaultRequest.","Cover custom implementations with a smoke test invoking authorize(state), login, revoke, refresh."],"tags":["justauth","oauth","not-implemented","interface-default-method"],"backgroundTag":null,"analyzedSha":"694bbf1b010d93404e3bfb4824d90e9ddfaebebb","analyzedAt":"2026-08-14T15:16:59.945Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}