{"record":{"id":"72959af75acaa3b0","repo":"justauth/JustAuth","slug":"object-getstring-error-72959a","errorCode":null,"errorMessage":"object.getString(\"error\")","messagePattern":"object\\.getString\\(\"error\"\\)","errorType":"exception","errorClass":"AuthException","httpStatus":null,"severity":"error","filePath":"src/main/java/me/zhyd/oauth/request/AuthHuaweiV3Request.java","lineNumber":188,"sourceCode":"            String codeVerifier = PkceUtil.generateCodeVerifier();\n            String codeChallengeMethod = \"S256\";\n            String codeChallenge = PkceUtil.generateCodeChallenge(codeChallengeMethod, codeVerifier);\n            builder.queryParam(\"code_challenge\", codeChallenge)\n                .queryParam(\"code_challenge_method\", codeChallengeMethod);\n            // 缓存 codeVerifier 十分钟\n            this.authStateCache.cache(cacheKey, codeVerifier, TimeUnit.MINUTES.toMillis(10));\n        }\n        return builder.build();\n    }\n\n    /**\n     * 校验响应结果\n     *\n     * @param object 接口返回的结果\n     */\n    private void checkResponse(JSONObject object) {\n        if (object.containsKey(\"NSP_STATUS\")) {\n            throw new AuthException(object.getString(\"error\"));\n        }\n        if (object.containsKey(\"error\")) {\n            throw new AuthException(object.getString(\"sub_error\") + \":\" + object.getString(\"error_description\"));\n        }\n    }\n\n\n}\n","sourceCodeStart":170,"sourceCodeEnd":197,"githubUrl":"https://github.com/justauth/JustAuth/blob/694bbf1b010d93404e3bfb4824d90e9ddfaebebb/src/main/java/me/zhyd/oauth/request/AuthHuaweiV3Request.java#L170-L197","documentation":"AuthException thrown by AuthHuaweiV3Request.checkResponse when the Huawei account API response contains the 'NSP_STATUS' key, which Huawei uses to signal a server-side processing error. The exception message is the raw value of the response's 'error' field. It usually means the token/code exchange or user-info call was rejected by Huawei (invalid client secret, bad code, wrong app ID, expired authorization).","triggerScenarios":"Calling getAccessToken/getUserInfo/revoke on an AuthHuaweiV3Request when Huawei responds with a JSON body containing NSP_STATUS (e.g. 10001 invalid grant, wrong appid/secret pair, or an already-consumed authorization code).","commonSituations":"Wrong Client Secret copied from AppGallery Console, App ID mismatch between config and the redirect URI whitelist, reusing a code after the redirect was processed twice, or the app being offline/unsynchronized in the console.","solutions":["Verify clientId/clientSecret match the Huawei AppGallery Connect app exactly (no trailing spaces)","Confirm redirectUri is registered in the Huawei console and that the authorization code is fresh (codes are single-use and short-lived)","Wrap the call in try-catch on AuthException and log the 'error' message; Huawei error codes (e.g. 10001, 10002) pinpoint the cause","If behind a proxy, verify HttpConfig reaches Huawei's endpoints without a captive portal mangling the response"],"exampleFix":"// before\nAuthToken token = authRequest.getAuthResponse(authCallback).getData();\n\n// after\ntry {\n    AuthToken token = authRequest.getAuthResponse(authCallback).getData();\n} catch (AuthException e) {\n    log.error(\"Huawei OAuth failed: {}\", e.getMessage()); // message is Huawei's 'error' field\n    throw e;\n}","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"try {\n    AuthResponse<AuthToken> resp = huaweiRequest.getAuthResponse(callback);\n} catch (AuthException e) {\n    // e.getMessage() is Huawei's raw 'error' value from the NSP_STATUS body\n    log.warn(\"Huawei OAuth error: {}\", e.getMessage());\n    return redirect(\"/login?error=huawei\");\n}","preventionTips":["Keep clientId/clientSecret in env config, not hardcoded values that rot between environments","Treat authorization codes as single-use; make the callback handler idempotent","Log full AuthException messages during integration to map Huawei error codes quickly"],"tags":["oauth","huawei","auth-exception","api-response"],"backgroundTag":null,"analyzedSha":"694bbf1b010d93404e3bfb4824d90e9ddfaebebb","analyzedAt":"2026-08-14T15:16:59.945Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}