w7corp/easywechat · error · HttpException
Failed to get jssdk ticket: %s
Error message
Failed to get jssdk ticket: %s
What it means
OpenWork\JsApiTicket::getTicket() serves the corp-level JS-SDK ticket from cache; on miss it GETs /cgi-bin/get_jsapi_ticket through the authorizer-aware HTTP client and throws HttpException (raw JSON embedded) when the response has no ticket. Like all ticket calls it rides on the authorizer access token, so credential-chain problems surface here even though the ticket endpoint itself is trivial.
Source
Thrown at src/OpenWork/JsApiTicket.php:71
return sha1(sprintf('jsapi_ticket=%s&noncestr=%s×tamp=%s&url=%s', $ticket, $nonce, $timestamp, $url));
}
/**
* @throws HttpException
*/
public function getTicket(): string
{
$key = $this->getKey();
$ticket = $this->cache->get($key);
if ($ticket && is_string($ticket)) {
return $ticket;
}
$response = $this->httpClient->request('GET', '/cgi-bin/get_jsapi_ticket')->toArray(false);
if (empty($response['ticket'])) {
throw new HttpException('Failed to get jssdk ticket: '.json_encode($response, JSON_UNESCAPED_UNICODE));
}
$this->cache->set($key, $response['ticket'], intval($response['expires_in']));
return $response['ticket'];
}
public function setKey(string $key): static
{
$this->key = $key;
return $this;
}
public function getKey(): string
{
return $this->key ?? $this->key = sprintf('open_work.jsapi_ticket.%s', $this->corpId);
}View on GitHub (pinned to f0cf0a8b83)
Solutions
- Decode the embedded errcode — 40001-class codes point at the credential chain, not the ticket API
- Verify the authorizer still has the app installed and re-run the install flow if not
- Refresh authorizer/suite tokens and clear the ticket cache, then retry
- Confirm the corp/app still holds JS-API permission and is not frozen
Defensive patterns
Strategy: try-catch
Try / catch
try {
$ticket = $jsApiTicket->getTicket();
} catch (\EasyWeChat\Kernel\Exceptions\HttpException $e) {
$payload = json_decode(strstr($e->getMessage(), '{') ?: '[]', true) ?: [];
if (($payload['errcode'] ?? null) === 40001) {
// credential chain broken: refresh authorizer/suite tokens, clear ticket cache, retry once
}
report($e);
} Prevention
- Watch this endpoint as a canary: it usually exposes authorizer-token breakage first
- Clear ticket cache alongside token cache whenever credentials change
- Disable JS-SDK pages for corps whose authorization is flagged revoked
When it happens
Trigger: Building wx.config signatures while the authorizer access token is invalid (authorization revoked, token expired and refresh failing downstream); the suite/authorizer credential chain broken; the corp restricted from JS-API usage.
Common situations: The authorizer uninstalled the suite app; signature pages breaking in bulk after an authorization change; cache wiped so tickets and tokens are re-fetched at once and the underlying token fetch fails first here.
Related errors
- Failed to get jssdk agentTicket: %s
- Failed to get jssdk ticket: %s
- Failed to get access_token: %s
- Failed to get auth_corp_info: %s
- Failed to get jssdk ticket: %s
AI-assisted analysis of w7corp/easywechat@f0cf0a8b83 (2026-08-21).
Data as JSON: /api/errors/9729868a7f0d4880.
Report an issue: GitHub.