{"record":{"id":"c05a29d1b562112a","repo":"w7corp/easywechat","slug":"failed-to-get-auth-corp-info-s","errorCode":null,"errorMessage":"Failed to get auth_corp_info: %s","messagePattern":"Failed to get auth_corp_info: (.+?)","errorType":"exception","errorClass":"HttpException","httpStatus":null,"severity":"error","filePath":"src/OpenWork/Application.php","lineNumber":225,"sourceCode":"    public function getAuthorization(\n        string $corpId,\n        string $permanentCode,\n        ?AccessTokenInterface $suiteAccessToken = null\n    ): Authorization {\n        $suiteAccessToken = $suiteAccessToken ?? $this->getSuiteAccessToken();\n\n        $response = $this->getHttpClient()->request('POST', 'cgi-bin/service/get_auth_info', [\n            'query' => [\n                'suite_access_token' => $suiteAccessToken->getToken(),\n            ],\n            'json' => [\n                'auth_corpid' => $corpId,\n                'permanent_code' => $permanentCode,\n            ],\n        ])->toArray(false);\n\n        if (empty($response['auth_corp_info'])) {\n            throw new HttpException('Failed to get auth_corp_info: '.json_encode($response, JSON_UNESCAPED_UNICODE));\n        }\n\n        return new Authorization($response);\n    }\n\n    public function getAuthorizerAccessToken(\n        string $corpId,\n        string $permanentCode,\n        ?AccessTokenInterface $suiteAccessToken = null\n    ): AuthorizerAccessToken {\n        $suiteAccessToken = $suiteAccessToken ?? $this->getSuiteAccessToken();\n\n        return new AuthorizerAccessToken(\n            corpId: $corpId,\n            permanentCodeOrAccessToken: $permanentCode,\n            suiteAccessToken: $suiteAccessToken,\n            cache: $this->getCache(),\n            httpClient: $this->getHttpClient(),","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/w7corp/easywechat/blob/f0cf0a8b8361417ed683b8246d0ecbaf0aafcaa8/src/OpenWork/Application.php#L207-L243","documentation":"OpenWork\\Application::getAuthorization() POSTs auth_corpid plus permanent_code to cgi-bin/service/get_auth_info, authenticated by the suite access token, and throws HttpException with the raw JSON when auth_corp_info is absent. WeChat Work declined to return the authorizer corp's profile for that permanent code.","triggerScenarios":"The corp revoked the suite app (permanent_code invalidated); the temporary auth code from the install redirect was passed instead of the exchanged permanent_code; permanent_code belongs to a different suite; suite_access_token expired or invalid so the query credential is rejected.","commonSituations":"An authorizer uninstalls the app from the WeChat Work admin; the DB stored the initial temporary code rather than the permanent one; rows lost or stale after partial migrations; idle installations with expired suite tokens.","solutions":["Decode the embedded errcode/errmsg to classify the refusal","Verify you stored and are sending the permanent_code obtained from the initial auth-code exchange, not the temporary code","If the authorization was revoked, mark that corp inactive and restart the install flow","Refresh the suite access token and retry the call once"],"exampleFix":"// before: using the temporary code from the install redirect\n$auth = $openWork->getAuthorization($corpId, $temporaryAuthCode);\n\n// after: query with the persisted permanent code from the initial exchange\n$auth = $openWork->getAuthorization($corpId, $row->permanent_code);","handlingStrategy":"try-catch","validationCode":"if (blank($permanentCode) || $permanentCode === $temporaryAuthCode) {\n    throw new \\RuntimeException('A valid permanent_code (not the temporary auth code) is required.');\n}","typeGuard":null,"tryCatchPattern":"try {\n    $auth = $openWork->getAuthorization($corpId, $permanentCode);\n} catch (\\EasyWeChat\\Kernel\\Exceptions\\HttpException $e) {\n    $payload = json_decode(strstr($e->getMessage(), '{') ?: '[]', true) ?: [];\n    // invalid permanent code → mark corp for reinstall; invalid suite credential → refresh suite token first\n    report($e);\n}","preventionTips":["Persist the permanent_code per corp at install time and never fall back to the temporary code","Track uninstall events so revoked corps are flagged before API calls fail","Refresh suite tokens proactively on a schedule instead of on-demand only"],"tags":["php","easywechat","wechat-work","open-work","authorization","permanent-code","http-error"],"backgroundTag":"authorization-info-fetch-failed","analyzedSha":"f0cf0a8b8361417ed683b8246d0ecbaf0aafcaa8","analyzedAt":"2026-08-21T05:29:19.565Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}